Skip to content

Commit 253a970

Browse files
committed
Miscellaneous small diagnostics cleanup
1 parent e708cbd commit 253a970

16 files changed

+20
-20
lines changed

compiler/rustc_trait_selection/src/traits/const_evaluatable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
117117
{
118118
err.span_help(
119119
tcx.def_span(def.did),
120-
&format!("try adding a `where` bound using this expression: where [u8; {}]: Sized", snippet),
120+
&format!("try adding a `where` bound using this expression: `where [u8; {}]: Sized`", snippet),
121121
);
122122
} else {
123123
err.span_help(

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1780,7 +1780,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
17801780
multispan.push_span_label(
17811781
sp,
17821782
format!(
1783-
"...if indirection was used here: `Box<{}>`",
1783+
"...if indirection were used here: `Box<{}>`",
17841784
param.name.ident(),
17851785
),
17861786
);

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
11031103
// This is currently not possible to trigger because E0038 takes precedence, but
11041104
// leave it in for completeness in case anything changes in an earlier stage.
11051105
err.note(&format!(
1106-
"if trait `{}` was object safe, you could return a trait object",
1106+
"if trait `{}` were object-safe, you could return a trait object",
11071107
trait_obj,
11081108
));
11091109
}

compiler/rustc_typeck/src/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ fn missing_items_err(
838838
// Obtain the level of indentation ending in `sugg_sp`.
839839
let indentation = tcx.sess.source_map().span_to_margin(sugg_sp).unwrap_or(0);
840840
// Make the whitespace that will make the suggestion have the right indentation.
841-
let padding: String = (0..indentation).map(|_| " ").collect();
841+
let padding: String = std::iter::repeat(" ").take(indentation).collect();
842842

843843
for trait_item in missing_items {
844844
let snippet = suggestion_signature(&trait_item, tcx);

src/test/ui/const-generics/const_evaluatable_checked/cross_crate_predicate.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: unconstrained generic constant
44
LL | let _ = const_evaluatable_lib::test1::<T>();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
help: try adding a `where` bound using this expression: where [u8; std::mem::size_of::<T>() - 1]: Sized
7+
help: try adding a `where` bound using this expression: `where [u8; std::mem::size_of::<T>() - 1]: Sized`
88
--> $DIR/auxiliary/const_evaluatable_lib.rs:6:10
99
|
1010
LL | [u8; std::mem::size_of::<T>() - 1]: Sized,
@@ -16,7 +16,7 @@ error: unconstrained generic constant
1616
LL | let _ = const_evaluatable_lib::test1::<T>();
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1818
|
19-
help: try adding a `where` bound using this expression: where [u8; std::mem::size_of::<T>() - 1]: Sized
19+
help: try adding a `where` bound using this expression: `where [u8; std::mem::size_of::<T>() - 1]: Sized`
2020
--> $DIR/auxiliary/const_evaluatable_lib.rs:4:27
2121
|
2222
LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1]
@@ -28,7 +28,7 @@ error: unconstrained generic constant
2828
LL | let _ = const_evaluatable_lib::test1::<T>();
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3030
|
31-
help: try adding a `where` bound using this expression: where [u8; std::mem::size_of::<T>() - 1]: Sized
31+
help: try adding a `where` bound using this expression: `where [u8; std::mem::size_of::<T>() - 1]: Sized`
3232
--> $DIR/auxiliary/const_evaluatable_lib.rs:6:10
3333
|
3434
LL | [u8; std::mem::size_of::<T>() - 1]: Sized,
@@ -40,7 +40,7 @@ error: unconstrained generic constant
4040
LL | let _ = const_evaluatable_lib::test1::<T>();
4141
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4242
|
43-
help: try adding a `where` bound using this expression: where [u8; std::mem::size_of::<T>() - 1]: Sized
43+
help: try adding a `where` bound using this expression: `where [u8; std::mem::size_of::<T>() - 1]: Sized`
4444
--> $DIR/auxiliary/const_evaluatable_lib.rs:4:27
4545
|
4646
LL | pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1]

src/test/ui/const-generics/const_evaluatable_checked/different-fn.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: unconstrained generic constant
44
LL | [0; size_of::<Foo<T>>()]
55
| ^^^^^^^^^^^^^^^^^^^
66
|
7-
help: try adding a `where` bound using this expression: where [u8; size_of::<Foo<T>>()]: Sized
7+
help: try adding a `where` bound using this expression: `where [u8; size_of::<Foo<T>>()]: Sized`
88
--> $DIR/different-fn.rs:10:9
99
|
1010
LL | [0; size_of::<Foo<T>>()]

src/test/ui/const_evaluatable/needs_where_clause.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: unconstrained generic constant
44
LL | b: [f32; complex_maths::<T>(N)],
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
help: try adding a `where` bound using this expression: where [u8; complex_maths::<T>(N)]: Sized
7+
help: try adding a `where` bound using this expression: `where [u8; complex_maths::<T>(N)]: Sized`
88
--> $DIR/needs_where_clause.rs:11:12
99
|
1010
LL | b: [f32; complex_maths::<T>(N)],

src/test/ui/const_evaluatable/no_where_clause.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: unconstrained generic constant
44
LL | b: [f32; complex_maths(N)],
55
| ^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
help: try adding a `where` bound using this expression: where [u8; complex_maths(N)]: Sized
7+
help: try adding a `where` bound using this expression: `where [u8; complex_maths(N)]: Sized`
88
--> $DIR/no_where_clause.rs:10:12
99
|
1010
LL | b: [f32; complex_maths(N)],

src/test/ui/issues/issue-18919.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ help: you could relax the implicit `Sized` bound on `T` if it were used through
1414
LL | enum Option<T> {
1515
| ^ this could be changed to `T: ?Sized`...
1616
LL | Some(T),
17-
| - ...if indirection was used here: `Box<T>`
17+
| - ...if indirection were used here: `Box<T>`
1818

1919
error: aborting due to previous error
2020

src/test/ui/issues/issue-23281.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ help: you could relax the implicit `Sized` bound on `T` if it were used through
1414
LL | struct Vec<T> {
1515
| ^ this could be changed to `T: ?Sized`...
1616
LL | t: T,
17-
| - ...if indirection was used here: `Box<T>`
17+
| - ...if indirection were used here: `Box<T>`
1818

1919
error: aborting due to previous error
2020

src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ help: you could relax the implicit `Sized` bound on `T` if it were used through
1313
--> $DIR/adt-param-with-implicit-sized-bound.rs:18:10
1414
|
1515
LL | struct X<T>(T);
16-
| ^ - ...if indirection was used here: `Box<T>`
16+
| ^ - ...if indirection were used here: `Box<T>`
1717
| |
1818
| this could be changed to `T: ?Sized`...
1919

@@ -68,7 +68,7 @@ help: you could relax the implicit `Sized` bound on `T` if it were used through
6868
LL | struct Struct3<T>{
6969
| ^ this could be changed to `T: ?Sized`...
7070
LL | _t: T,
71-
| - ...if indirection was used here: `Box<T>`
71+
| - ...if indirection were used here: `Box<T>`
7272
help: consider further restricting `Self`
7373
|
7474
LL | fn func3() -> Struct3<Self> where Self: Sized;

src/test/ui/unsized/unsized-enum.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ help: you could relax the implicit `Sized` bound on `U` if it were used through
1313
--> $DIR/unsized-enum.rs:4:10
1414
|
1515
LL | enum Foo<U> { FooSome(U), FooNone }
16-
| ^ - ...if indirection was used here: `Box<U>`
16+
| ^ - ...if indirection were used here: `Box<U>`
1717
| |
1818
| this could be changed to `U: ?Sized`...
1919

src/test/ui/unsized/unsized-inherent-impl-self-type.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ help: you could relax the implicit `Sized` bound on `Y` if it were used through
1313
--> $DIR/unsized-inherent-impl-self-type.rs:5:11
1414
|
1515
LL | struct S5<Y>(Y);
16-
| ^ - ...if indirection was used here: `Box<Y>`
16+
| ^ - ...if indirection were used here: `Box<Y>`
1717
| |
1818
| this could be changed to `Y: ?Sized`...
1919

src/test/ui/unsized/unsized-struct.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ help: you could relax the implicit `Sized` bound on `T` if it were used through
1313
--> $DIR/unsized-struct.rs:4:12
1414
|
1515
LL | struct Foo<T> { data: T }
16-
| ^ - ...if indirection was used here: `Box<T>`
16+
| ^ - ...if indirection were used here: `Box<T>`
1717
| |
1818
| this could be changed to `T: ?Sized`...
1919

src/test/ui/unsized/unsized-trait-impl-self-type.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ help: you could relax the implicit `Sized` bound on `Y` if it were used through
1313
--> $DIR/unsized-trait-impl-self-type.rs:8:11
1414
|
1515
LL | struct S5<Y>(Y);
16-
| ^ - ...if indirection was used here: `Box<Y>`
16+
| ^ - ...if indirection were used here: `Box<Y>`
1717
| |
1818
| this could be changed to `Y: ?Sized`...
1919

src/test/ui/wf/wf-fn-where-clause.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ help: you could relax the implicit `Sized` bound on `T` if it were used through
2828
LL | struct Vec<T> {
2929
| ^ this could be changed to `T: ?Sized`...
3030
LL | t: T,
31-
| - ...if indirection was used here: `Box<T>`
31+
| - ...if indirection were used here: `Box<T>`
3232

3333
error[E0038]: the trait `Copy` cannot be made into an object
3434
--> $DIR/wf-fn-where-clause.rs:12:16

0 commit comments

Comments
 (0)