Skip to content

Commit 936d760

Browse files
authored
Rollup merge of #126127 - Alexendoo:other-trait-diag, r=pnkfelix
Spell out other trait diagnostic I recently saw somebody confused about the diagnostic thinking it was suggesting to add an `as` cast. This change is longer but I think it's clearer
2 parents e4bc7de + d0112c6 commit 936d760

File tree

42 files changed

+348
-348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+348
-348
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2068,7 +2068,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
20682068
if all_traits_equal {
20692069
format!("\n {}", c.self_ty())
20702070
} else {
2071-
format!("\n {c}")
2071+
format!("\n `{}` implements `{}`", c.self_ty(), c.print_only_trait_path())
20722072
}
20732073
})
20742074
.collect();

tests/ui/binop/binary-op-suggest-deref.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,10 @@ LL | let _ = FOO & (*"Sized".to_string().into_boxed_str());
303303
|
304304
= help: the trait `BitAnd<str>` is not implemented for `i32`
305305
= help: the following other types implement trait `BitAnd<Rhs>`:
306-
<&'a i32 as BitAnd<i32>>
307-
<&i32 as BitAnd<&i32>>
308-
<i32 as BitAnd<&i32>>
309-
<i32 as BitAnd>
306+
`&'a i32` implements `BitAnd<i32>`
307+
`&i32` implements `BitAnd<&i32>`
308+
`i32` implements `BitAnd<&i32>`
309+
`i32` implements `BitAnd`
310310

311311
error[E0277]: the size for values of type `str` cannot be known at compilation time
312312
--> $DIR/binary-op-suggest-deref.rs:78:17

tests/ui/binop/binop-mul-i32-f32.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ LL | x * y
66
|
77
= help: the trait `Mul<f32>` is not implemented for `i32`
88
= help: the following other types implement trait `Mul<Rhs>`:
9-
<&'a i32 as Mul<i32>>
10-
<&i32 as Mul<&i32>>
11-
<i32 as Mul<&i32>>
12-
<i32 as Mul>
9+
`&'a i32` implements `Mul<i32>`
10+
`&i32` implements `Mul<&i32>`
11+
`i32` implements `Mul<&i32>`
12+
`i32` implements `Mul`
1313

1414
error: aborting due to 1 previous error
1515

tests/ui/binop/shift-various-bad-types.stderr

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ LL | 22 >> p.char;
66
|
77
= help: the trait `Shr<char>` is not implemented for `{integer}`
88
= help: the following other types implement trait `Shr<Rhs>`:
9-
<&'a i128 as Shr<i128>>
10-
<&'a i128 as Shr<i16>>
11-
<&'a i128 as Shr<i32>>
12-
<&'a i128 as Shr<i64>>
13-
<&'a i128 as Shr<i8>>
14-
<&'a i128 as Shr<isize>>
15-
<&'a i128 as Shr<u128>>
16-
<&'a i128 as Shr<u16>>
9+
`&'a i128` implements `Shr<i128>`
10+
`&'a i128` implements `Shr<i16>`
11+
`&'a i128` implements `Shr<i32>`
12+
`&'a i128` implements `Shr<i64>`
13+
`&'a i128` implements `Shr<i8>`
14+
`&'a i128` implements `Shr<isize>`
15+
`&'a i128` implements `Shr<u128>`
16+
`&'a i128` implements `Shr<u16>`
1717
and 568 others
1818

1919
error[E0277]: no implementation for `{integer} >> &str`
@@ -24,14 +24,14 @@ LL | 22 >> p.str;
2424
|
2525
= help: the trait `Shr<&str>` is not implemented for `{integer}`
2626
= help: the following other types implement trait `Shr<Rhs>`:
27-
<&'a i128 as Shr<i128>>
28-
<&'a i128 as Shr<i16>>
29-
<&'a i128 as Shr<i32>>
30-
<&'a i128 as Shr<i64>>
31-
<&'a i128 as Shr<i8>>
32-
<&'a i128 as Shr<isize>>
33-
<&'a i128 as Shr<u128>>
34-
<&'a i128 as Shr<u16>>
27+
`&'a i128` implements `Shr<i128>`
28+
`&'a i128` implements `Shr<i16>`
29+
`&'a i128` implements `Shr<i32>`
30+
`&'a i128` implements `Shr<i64>`
31+
`&'a i128` implements `Shr<i8>`
32+
`&'a i128` implements `Shr<isize>`
33+
`&'a i128` implements `Shr<u128>`
34+
`&'a i128` implements `Shr<u16>`
3535
and 568 others
3636

3737
error[E0277]: no implementation for `{integer} >> &Panolpy`
@@ -42,14 +42,14 @@ LL | 22 >> p;
4242
|
4343
= help: the trait `Shr<&Panolpy>` is not implemented for `{integer}`
4444
= help: the following other types implement trait `Shr<Rhs>`:
45-
<&'a i128 as Shr<i128>>
46-
<&'a i128 as Shr<i16>>
47-
<&'a i128 as Shr<i32>>
48-
<&'a i128 as Shr<i64>>
49-
<&'a i128 as Shr<i8>>
50-
<&'a i128 as Shr<isize>>
51-
<&'a i128 as Shr<u128>>
52-
<&'a i128 as Shr<u16>>
45+
`&'a i128` implements `Shr<i128>`
46+
`&'a i128` implements `Shr<i16>`
47+
`&'a i128` implements `Shr<i32>`
48+
`&'a i128` implements `Shr<i64>`
49+
`&'a i128` implements `Shr<i8>`
50+
`&'a i128` implements `Shr<isize>`
51+
`&'a i128` implements `Shr<u128>`
52+
`&'a i128` implements `Shr<u16>`
5353
and 568 others
5454

5555
error[E0308]: mismatched types

tests/ui/const-generics/exhaustive-value.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ LL | <() as Foo<N>>::test()
55
| ^^ the trait `Foo<N>` is not implemented for `()`
66
|
77
= help: the following other types implement trait `Foo<N>`:
8-
<() as Foo<0>>
9-
<() as Foo<100>>
10-
<() as Foo<101>>
11-
<() as Foo<102>>
12-
<() as Foo<103>>
13-
<() as Foo<104>>
14-
<() as Foo<105>>
15-
<() as Foo<106>>
8+
`()` implements `Foo<0>`
9+
`()` implements `Foo<100>`
10+
`()` implements `Foo<101>`
11+
`()` implements `Foo<102>`
12+
`()` implements `Foo<103>`
13+
`()` implements `Foo<104>`
14+
`()` implements `Foo<105>`
15+
`()` implements `Foo<106>`
1616
and 248 others
1717

1818
error: aborting due to 1 previous error

tests/ui/consts/const-eval/const-eval-overflow-3b.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ LL | = [0; (i8::MAX + 1u8) as usize];
1212
|
1313
= help: the trait `Add<u8>` is not implemented for `i8`
1414
= help: the following other types implement trait `Add<Rhs>`:
15-
<&'a i8 as Add<i8>>
16-
<&i8 as Add<&i8>>
17-
<i8 as Add<&i8>>
18-
<i8 as Add>
15+
`&'a i8` implements `Add<i8>`
16+
`&i8` implements `Add<&i8>`
17+
`i8` implements `Add<&i8>`
18+
`i8` implements `Add`
1919

2020
error: aborting due to 2 previous errors
2121

tests/ui/consts/const-eval/const-eval-overflow-4b.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ LL | : [u32; (i8::MAX as i8 + 1u8) as usize]
1212
|
1313
= help: the trait `Add<u8>` is not implemented for `i8`
1414
= help: the following other types implement trait `Add<Rhs>`:
15-
<&'a i8 as Add<i8>>
16-
<&i8 as Add<&i8>>
17-
<i8 as Add<&i8>>
18-
<i8 as Add>
15+
`&'a i8` implements `Add<i8>`
16+
`&i8` implements `Add<&i8>`
17+
`i8` implements `Add<&i8>`
18+
`i8` implements `Add`
1919

2020
error[E0604]: only `u8` can be cast as `char`, not `i8`
2121
--> $DIR/const-eval-overflow-4b.rs:22:13

tests/ui/consts/too_generic_eval_ice.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ LL | [5; Self::HOST_SIZE] == [6; 0]
2222
|
2323
= help: the trait `PartialEq<[{integer}; 0]>` is not implemented for `[{integer}; Self::HOST_SIZE]`
2424
= help: the following other types implement trait `PartialEq<Rhs>`:
25-
<&[T] as PartialEq<Vec<U, A>>>
26-
<&[T] as PartialEq<[U; N]>>
27-
<&mut [T] as PartialEq<Vec<U, A>>>
28-
<&mut [T] as PartialEq<[U; N]>>
29-
<[T; N] as PartialEq<&[U]>>
30-
<[T; N] as PartialEq<&mut [U]>>
31-
<[T; N] as PartialEq<[U; N]>>
32-
<[T; N] as PartialEq<[U]>>
25+
`&[T]` implements `PartialEq<Vec<U, A>>`
26+
`&[T]` implements `PartialEq<[U; N]>`
27+
`&mut [T]` implements `PartialEq<Vec<U, A>>`
28+
`&mut [T]` implements `PartialEq<[U; N]>`
29+
`[T; N]` implements `PartialEq<&[U]>`
30+
`[T; N]` implements `PartialEq<&mut [U]>`
31+
`[T; N]` implements `PartialEq<[U; N]>`
32+
`[T; N]` implements `PartialEq<[U]>`
3333
and 3 others
3434

3535
error: aborting due to 3 previous errors

tests/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | f1.foo(1usize);
77
| required by a bound introduced by this call
88
|
99
= help: the following other types implement trait `Foo<A>`:
10-
<Bar as Foo<i32>>
11-
<Bar as Foo<u8>>
10+
`Bar` implements `Foo<i32>`
11+
`Bar` implements `Foo<u8>`
1212

1313
error: aborting due to 1 previous error
1414

tests/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ LL | f1.foo(1usize);
77
| required by a bound introduced by this call
88
|
99
= help: the following other types implement trait `Foo<A>`:
10-
<Bar as Foo<i16>>
11-
<Bar as Foo<i32>>
12-
<Bar as Foo<i8>>
13-
<Bar as Foo<u16>>
14-
<Bar as Foo<u32>>
15-
<Bar as Foo<u8>>
10+
`Bar` implements `Foo<i16>`
11+
`Bar` implements `Foo<i32>`
12+
`Bar` implements `Foo<i8>`
13+
`Bar` implements `Foo<u16>`
14+
`Bar` implements `Foo<u32>`
15+
`Bar` implements `Foo<u8>`
1616

1717
error: aborting due to 1 previous error
1818

0 commit comments

Comments
 (0)