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

+2-2
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

+1-1
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

+3-3
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

+2-2
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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>>

src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | Foo::<i32>::bar(&1i8);
66
| |
77
| required by a bound introduced by this call
88
|
9-
= help: the following other types implement trait `Foo<bool>`:
9+
= help: the following other types implement trait `Foo<B>`:
1010
<i8 as Foo<bool>>
1111
<i8 as Foo<u16>>
1212
<i8 as Foo<u32>>
@@ -25,7 +25,7 @@ LL | Foo::<i32>::bar(&1u8);
2525
| |
2626
| required by a bound introduced by this call
2727
|
28-
= help: the following other types implement trait `Foo<bool>`:
28+
= help: the following other types implement trait `Foo<B>`:
2929
<i8 as Foo<bool>>
3030
<i8 as Foo<u16>>
3131
<i8 as Foo<u32>>
@@ -44,7 +44,7 @@ LL | Foo::<i32>::bar(&true);
4444
| |
4545
| required by a bound introduced by this call
4646
|
47-
= help: the following other types implement trait `Foo<bool>`:
47+
= help: the following other types implement trait `Foo<B>`:
4848
<bool as Foo<bool>>
4949
<bool as Foo<i8>>
5050
<bool as Foo<u16>>

src/test/ui/did_you_mean/issue-49746-unicode-confusable-in-float-literal-expt.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e−11; // m³⋅kg⁻¹
2222
| ^ no implementation for `{float} - {integer}`
2323
|
2424
= help: the trait `Sub<{integer}>` is not implemented for `{float}`
25-
= help: the following other types implement trait `Sub`:
25+
= help: the following other types implement trait `Sub<Rhs>`:
2626
<&'a f32 as Sub<f32>>
2727
<&'a f64 as Sub<f64>>
2828
<&'a i128 as Sub<i128>>

src/test/ui/impl-trait/equality.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ LL | n + sum_to(n - 1)
2424
| ^ no implementation for `u32 + impl Foo`
2525
|
2626
= help: the trait `Add<impl Foo>` is not implemented for `u32`
27-
= help: the following other types implement trait `Add`:
27+
= help: the following other types implement trait `Add<Rhs>`:
2828
<&'a f32 as Add<f32>>
2929
<&'a f64 as Add<f64>>
3030
<&'a i128 as Add<i128>>

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | 1 +
55
| ^ no implementation for `{integer} + ()`
66
|
77
= help: the trait `Add<()>` is not implemented for `{integer}`
8-
= help: the following other types implement trait `Add`:
8+
= help: the following other types implement trait `Add<Rhs>`:
99
<&'a f32 as Add<f32>>
1010
<&'a f64 as Add<f64>>
1111
<&'a i128 as Add<i128>>
@@ -23,7 +23,7 @@ LL | 1 +
2323
| ^ no implementation for `{integer} + ()`
2424
|
2525
= help: the trait `Add<()>` is not implemented for `{integer}`
26-
= help: the following other types implement trait `Add`:
26+
= help: the following other types implement trait `Add<Rhs>`:
2727
<&'a f32 as Add<f32>>
2828
<&'a f64 as Add<f64>>
2929
<&'a i128 as Add<i128>>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | 1.0f64 - 1
55
| ^ no implementation for `f64 - {integer}`
66
|
77
= help: the trait `Sub<{integer}>` is not implemented for `f64`
8-
= help: the following other types implement trait `Sub`:
8+
= help: the following other types implement trait `Sub<Rhs>`:
99
<&'a f32 as Sub<f32>>
1010
<&'a f64 as Sub<f64>>
1111
<&'a i128 as Sub<i128>>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new();
1414
| ^ no implementation for `{integer} + ()`
1515
|
1616
= help: the trait `Add<()>` is not implemented for `{integer}`
17-
= help: the following other types implement trait `Add`:
17+
= help: the following other types implement trait `Add<Rhs>`:
1818
<&'a f32 as Add<f32>>
1919
<&'a f64 as Add<f64>>
2020
<&'a i128 as Add<i128>>

src/test/ui/lexer/lex-bad-char-literals-6.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ LL | if x == y {}
3838
| ^^ no implementation for `&str == char`
3939
|
4040
= help: the trait `PartialEq<char>` is not implemented for `&str`
41-
= help: the following other types implement trait `PartialEq<Cow<'a, str>>`:
41+
= help: the following other types implement trait `PartialEq<Rhs>`:
4242
<&'a str as PartialEq<OsString>>
4343
<&'a str as PartialEq<String>>
4444
<&'b str as PartialEq<Cow<'a, str>>>
@@ -64,7 +64,7 @@ LL | if x == z {}
6464
| ^^ no implementation for `&str == char`
6565
|
6666
= help: the trait `PartialEq<char>` is not implemented for `&str`
67-
= help: the following other types implement trait `PartialEq<Cow<'a, str>>`:
67+
= help: the following other types implement trait `PartialEq<Rhs>`:
6868
<&'a str as PartialEq<OsString>>
6969
<&'a str as PartialEq<String>>
7070
<&'b str as PartialEq<Cow<'a, str>>>

src/test/ui/mismatched_types/binops.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | 1 + Some(1);
55
| ^ no implementation for `{integer} + Option<{integer}>`
66
|
77
= help: the trait `Add<Option<{integer}>>` is not implemented for `{integer}`
8-
= help: the following other types implement trait `Add`:
8+
= help: the following other types implement trait `Add<Rhs>`:
99
<&'a f32 as Add<f32>>
1010
<&'a f64 as Add<f64>>
1111
<&'a i128 as Add<i128>>
@@ -23,7 +23,7 @@ LL | 2 as usize - Some(1);
2323
| ^ no implementation for `usize - Option<{integer}>`
2424
|
2525
= help: the trait `Sub<Option<{integer}>>` is not implemented for `usize`
26-
= help: the following other types implement trait `Sub`:
26+
= help: the following other types implement trait `Sub<Rhs>`:
2727
<&'a f32 as Sub<f32>>
2828
<&'a f64 as Sub<f64>>
2929
<&'a i128 as Sub<i128>>
@@ -41,7 +41,7 @@ LL | 3 * ();
4141
| ^ no implementation for `{integer} * ()`
4242
|
4343
= help: the trait `Mul<()>` is not implemented for `{integer}`
44-
= help: the following other types implement trait `Mul`:
44+
= help: the following other types implement trait `Mul<Rhs>`:
4545
<&'a f32 as Mul<f32>>
4646
<&'a f64 as Mul<f64>>
4747
<&'a i128 as Mul<i128>>
@@ -59,7 +59,7 @@ LL | 4 / "";
5959
| ^ no implementation for `{integer} / &str`
6060
|
6161
= help: the trait `Div<&str>` is not implemented for `{integer}`
62-
= help: the following other types implement trait `Div`:
62+
= help: the following other types implement trait `Div<Rhs>`:
6363
<&'a f32 as Div<f32>>
6464
<&'a f64 as Div<f64>>
6565
<&'a i128 as Div<i128>>
@@ -77,7 +77,7 @@ LL | 5 < String::new();
7777
| ^ no implementation for `{integer} < String` and `{integer} > String`
7878
|
7979
= help: the trait `PartialOrd<String>` is not implemented for `{integer}`
80-
= help: the following other types implement trait `PartialOrd`:
80+
= help: the following other types implement trait `PartialOrd<Rhs>`:
8181
f32
8282
f64
8383
i128
@@ -95,7 +95,7 @@ LL | 6 == Ok(1);
9595
| ^^ no implementation for `{integer} == Result<{integer}, _>`
9696
|
9797
= help: the trait `PartialEq<Result<{integer}, _>>` is not implemented for `{integer}`
98-
= help: the following other types implement trait `PartialEq`:
98+
= help: the following other types implement trait `PartialEq<Rhs>`:
9999
f32
100100
f64
101101
i128

src/test/ui/never_type/issue-13352.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | 2_usize + (loop {});
55
| ^ no implementation for `usize + ()`
66
|
77
= help: the trait `Add<()>` is not implemented for `usize`
8-
= help: the following other types implement trait `Add`:
8+
= help: the following other types implement trait `Add<Rhs>`:
99
<&'a f32 as Add<f32>>
1010
<&'a f64 as Add<f64>>
1111
<&'a i128 as Add<i128>>

0 commit comments

Comments
 (0)