Skip to content

Commit 3109c93

Browse files
committed
Refer to the TraitRef::identity in the message to be clearer
1 parent ef91519 commit 3109c93

33 files changed

+71
-71
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,13 +1763,12 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
17631763
if candidates.len() == 0 {
17641764
return false;
17651765
}
1766-
let trait_ref = candidates[0];
17671766
if candidates.len() == 1 {
17681767
err.highlighted_help(vec![
17691768
(
17701769
format!(
17711770
"the trait `{}` is implemented for `",
1772-
trait_ref.print_only_trait_path()
1771+
candidates[0].print_only_trait_path()
17731772
),
17741773
Style::NoStyle,
17751774
),
@@ -1778,6 +1777,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
17781777
]);
17791778
return true;
17801779
}
1780+
let trait_ref = TraitRef::identity(self.tcx, candidates[0].def_id);
17811781
// Check if the trait is the same in all cases. If so, we'll only show the type.
17821782
// FIXME: there *has* to be a better way!
17831783
let mut traits: Vec<_> = candidates

src/test/ui/binop/binop-mul-i32-f32.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | x * y
55
| ^ no implementation for `i32 * f32`
66
|
77
= help: the trait `Mul<f32>` is not implemented for `i32`
8-
= help: the following other types implement trait `Mul`:
8+
= help: the following other types implement trait `Mul<Rhs>`:
99
<&'a f32 as Mul<f32>>
1010
<&'a f64 as Mul<f64>>
1111
<&'a i128 as Mul<i128>>

src/test/ui/binop/shift-various-bad-types.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | 22 >> p.char;
55
| ^^ no implementation for `{integer} >> char`
66
|
77
= help: the trait `Shr<char>` is not implemented for `{integer}`
8-
= help: the following other types implement trait `Shr`:
8+
= help: the following other types implement trait `Shr<Rhs>`:
99
<&'a i128 as Shr<i128>>
1010
<&'a i128 as Shr<i16>>
1111
<&'a i128 as Shr<i32>>
@@ -23,7 +23,7 @@ LL | 22 >> p.str;
2323
| ^^ no implementation for `{integer} >> &str`
2424
|
2525
= help: the trait `Shr<&str>` is not implemented for `{integer}`
26-
= help: the following other types implement trait `Shr`:
26+
= help: the following other types implement trait `Shr<Rhs>`:
2727
<&'a i128 as Shr<i128>>
2828
<&'a i128 as Shr<i16>>
2929
<&'a i128 as Shr<i32>>
@@ -41,7 +41,7 @@ LL | 22 >> p;
4141
| ^^ no implementation for `{integer} >> &Panolpy`
4242
|
4343
= help: the trait `Shr<&Panolpy>` is not implemented for `{integer}`
44-
= help: the following other types implement trait `Shr`:
44+
= help: the following other types implement trait `Shr<Rhs>`:
4545
<&'a i128 as Shr<i128>>
4646
<&'a i128 as Shr<i16>>
4747
<&'a i128 as Shr<i32>>

src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ error[E0277]: the trait bound `u32: Traitor<N, N>` is not satisfied
2525
LL | fn uwu<const N: u8>() -> impl Traitor<N> {
2626
| ^^^^^^^^^^^^^^^ the trait `Traitor<N, N>` is not implemented for `u32`
2727
|
28-
= help: the following other types implement trait `Traitor<N, 2_u8>`:
28+
= help: the following other types implement trait `Traitor<N, M>`:
2929
<u32 as Traitor<N, 2_u8>>
3030
<u64 as Traitor<1_u8, 2_u8>>
3131

@@ -50,7 +50,7 @@ error[E0277]: the trait bound `u64: Traitor<1_u8, 1_u8>` is not satisfied
5050
LL | fn owo() -> impl Traitor {
5151
| ^^^^^^^^^^^^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64`
5252
|
53-
= help: the following other types implement trait `Traitor<N, 2_u8>`:
53+
= help: the following other types implement trait `Traitor<N, M>`:
5454
<u32 as Traitor<N, 2_u8>>
5555
<u64 as Traitor<1_u8, 2_u8>>
5656

src/test/ui/const-generics/exhaustive-value.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0277]: the trait bound `(): Foo<N>` is not satisfied
44
LL | <() as Foo<N>>::test()
55
| ^^^^^^^^^^^^^^^^^^^^ the trait `Foo<N>` is not implemented for `()`
66
|
7-
= help: the following other types implement trait `Foo<0_u8>`:
7+
= help: the following other types implement trait `Foo<N>`:
88
<() as Foo<0_u8>>
99
<() as Foo<100_u8>>
1010
<() as Foo<101_u8>>

src/test/ui/consts/const-eval/const-eval-overflow-3b.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LL | = [0; (i8::MAX + 1u8) as usize];
1111
| ^ no implementation for `i8 + u8`
1212
|
1313
= help: the trait `Add<u8>` is not implemented for `i8`
14-
= help: the following other types implement trait `Add`:
14+
= help: the following other types implement trait `Add<Rhs>`:
1515
<&'a f32 as Add<f32>>
1616
<&'a f64 as Add<f64>>
1717
<&'a i128 as Add<i128>>

src/test/ui/consts/const-eval/const-eval-overflow-4b.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LL | : [u32; (i8::MAX as i8 + 1u8) as usize]
1111
| ^ no implementation for `i8 + u8`
1212
|
1313
= help: the trait `Add<u8>` is not implemented for `i8`
14-
= help: the following other types implement trait `Add`:
14+
= help: the following other types implement trait `Add<Rhs>`:
1515
<&'a f32 as Add<f32>>
1616
<&'a f64 as Add<f64>>
1717
<&'a i128 as Add<i128>>

src/test/ui/consts/too_generic_eval_ice.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ LL | [5; Self::HOST_SIZE] == [6; 0]
2121
| ^^ no implementation for `[{integer}; _] == [{integer}; 0]`
2222
|
2323
= help: the trait `PartialEq<[{integer}; 0]>` is not implemented for `[{integer}; _]`
24-
= help: the following other types implement trait `PartialEq<[B; N]>`:
24+
= help: the following other types implement trait `PartialEq<Rhs>`:
2525
<&[B] as PartialEq<[A; N]>>
2626
<&[T] as PartialEq<Vec<U, A>>>
2727
<&mut [B] as PartialEq<[A; N]>>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0277]: the trait bound `Bar: Foo<usize>` is not satisfied
44
LL | f1.foo(1usize);
55
| ^^^ the trait `Foo<usize>` is not implemented for `Bar`
66
|
7-
= help: the following other types implement trait `Foo<i32>`:
7+
= help: the following other types implement trait `Foo<A>`:
88
<Bar as Foo<i32>>
99
<Bar as Foo<u8>>
1010

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0277]: the trait bound `Bar: Foo<usize>` is not satisfied
44
LL | f1.foo(1usize);
55
| ^^^ the trait `Foo<usize>` is not implemented for `Bar`
66
|
7-
= help: the following other types implement trait `Foo<i8>`:
7+
= help: the following other types implement trait `Foo<A>`:
88
<Bar as Foo<i16>>
99
<Bar as Foo<i32>>
1010
<Bar as Foo<i8>>

0 commit comments

Comments
 (0)