about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs9
-rw-r--r--src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr6
-rw-r--r--src/test/ui/kindck/kindck-impl-type-params.nll.stderr2
-rw-r--r--src/test/ui/traits/suggest-deferences/root-obligation.fixed1
-rw-r--r--src/test/ui/traits/suggest-deferences/root-obligation.rs1
-rw-r--r--src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr2
-rw-r--r--src/test/ui/type-alias-impl-trait/self-referential-2.stderr14
-rw-r--r--src/test/ui/type-alias-impl-trait/self-referential-4.stderr42
-rw-r--r--src/test/ui/type-alias-impl-trait/self-referential.stderr42
9 files changed, 72 insertions, 47 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
index de35f545f06..408c2ab9675 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
@@ -1756,7 +1756,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
         trait_ref: ty::PolyTraitRef<'tcx>,
         err: &mut Diagnostic,
     ) -> bool {
-        let report = |mut candidates: Vec<TraitRef<'_>>, err: &mut Diagnostic| {
+        let report = |mut candidates: Vec<TraitRef<'tcx>>, err: &mut Diagnostic| {
             candidates.sort();
             candidates.dedup();
             let len = candidates.len();
@@ -1778,11 +1778,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
             }
             let trait_ref = TraitRef::identity(self.tcx, candidates[0].def_id);
             // Check if the trait is the same in all cases. If so, we'll only show the type.
-            // FIXME: there *has* to be a better way!
-            let mut traits: Vec<_> = candidates
-                .iter()
-                .map(|c| format!("{}", c).split(" as ").last().unwrap().to_string())
-                .collect();
+            let mut traits: Vec<_> =
+                candidates.iter().map(|c| c.print_only_trait_path().to_string()).collect();
             traits.sort();
             traits.dedup();
 
diff --git a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr
index 1fb6b38e4a6..48c61c22e7a 100644
--- a/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr
+++ b/src/test/ui/const-generics/defaults/rp_impl_trait_fail.stderr
@@ -40,7 +40,7 @@ LL | |     1_u32
 LL | | }
    | |_^ the trait `Traitor<N, N>` is not implemented for `u32`
    |
-   = help: the following implementations were found:
+   = help: the following other types implement trait `Traitor<N, M>`:
              <u32 as Traitor<N, 2_u8>>
              <u64 as Traitor<1_u8, 2_u8>>
 
@@ -65,9 +65,9 @@ LL | |     1_u64
 LL | | }
    | |_^ the trait `Traitor<1_u8, 1_u8>` is not implemented for `u64`
    |
-   = help: the following implementations were found:
-             <u64 as Traitor<1_u8, 2_u8>>
+   = help: the following other types implement trait `Traitor<N, M>`:
              <u32 as Traitor<N, 2_u8>>
+             <u64 as Traitor<1_u8, 2_u8>>
 
 error: aborting due to 6 previous errors
 
diff --git a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr
index 7129bad8a97..94f802620a3 100644
--- a/src/test/ui/kindck/kindck-impl-type-params.nll.stderr
+++ b/src/test/ui/kindck/kindck-impl-type-params.nll.stderr
@@ -72,6 +72,7 @@ error[E0277]: the trait bound `String: Copy` is not satisfied
 LL |     let a = t as Box<dyn Gettable<String>>;
    |             ^ the trait `Copy` is not implemented for `String`
    |
+   = help: the trait `Gettable<T>` is implemented for `S<T>`
 note: required because of the requirements on the impl of `Gettable<String>` for `S<String>`
   --> $DIR/kindck-impl-type-params.rs:14:32
    |
@@ -85,6 +86,7 @@ error[E0277]: the trait bound `Foo: Copy` is not satisfied
 LL |     let a: Box<dyn Gettable<Foo>> = t;
    |                                     ^ the trait `Copy` is not implemented for `Foo`
    |
+   = help: the trait `Gettable<T>` is implemented for `S<T>`
 note: required because of the requirements on the impl of `Gettable<Foo>` for `S<Foo>`
   --> $DIR/kindck-impl-type-params.rs:14:32
    |
diff --git a/src/test/ui/traits/suggest-deferences/root-obligation.fixed b/src/test/ui/traits/suggest-deferences/root-obligation.fixed
index 9fd19240678..7a8433f9057 100644
--- a/src/test/ui/traits/suggest-deferences/root-obligation.fixed
+++ b/src/test/ui/traits/suggest-deferences/root-obligation.fixed
@@ -11,4 +11,3 @@ fn get_vowel_count(string: &str) -> usize {
 fn main() {
     let _ = get_vowel_count("asdf");
 }
-
diff --git a/src/test/ui/traits/suggest-deferences/root-obligation.rs b/src/test/ui/traits/suggest-deferences/root-obligation.rs
index 4dd0291b629..51bac2107e3 100644
--- a/src/test/ui/traits/suggest-deferences/root-obligation.rs
+++ b/src/test/ui/traits/suggest-deferences/root-obligation.rs
@@ -11,4 +11,3 @@ fn get_vowel_count(string: &str) -> usize {
 fn main() {
     let _ = get_vowel_count("asdf");
 }
-
diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr
index 9a3fd2f4005..264e8024fac 100644
--- a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr
+++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr
@@ -19,7 +19,7 @@ LL | |     ()
 LL | | }
    | |_^ the trait `Foo<FooX>` is not implemented for `()`
    |
-   = help: the following implementations were found:
+   = help: the following other types implement trait `Foo<A>`:
              <() as Foo<()>>
              <() as Foo<u32>>
 
diff --git a/src/test/ui/type-alias-impl-trait/self-referential-2.stderr b/src/test/ui/type-alias-impl-trait/self-referential-2.stderr
index b93ded6a7d3..348696f25e3 100644
--- a/src/test/ui/type-alias-impl-trait/self-referential-2.stderr
+++ b/src/test/ui/type-alias-impl-trait/self-referential-2.stderr
@@ -5,11 +5,15 @@ LL |     42_i32
    |     ^^^^^^ no implementation for `i32 == Foo`
    |
    = help: the trait `PartialEq<Foo>` is not implemented for `i32`
-   = help: the following implementations were found:
-             <i32 as PartialEq>
-             <f32 as PartialEq>
-             <f64 as PartialEq>
-             <i128 as PartialEq>
+   = help: the following other types implement trait `PartialEq<Rhs>`:
+             f32
+             f64
+             i128
+             i16
+             i32
+             i64
+             i8
+             isize
            and 6 others
 
 error: aborting due to previous error
diff --git a/src/test/ui/type-alias-impl-trait/self-referential-4.stderr b/src/test/ui/type-alias-impl-trait/self-referential-4.stderr
index 23ca6890196..83826479419 100644
--- a/src/test/ui/type-alias-impl-trait/self-referential-4.stderr
+++ b/src/test/ui/type-alias-impl-trait/self-referential-4.stderr
@@ -5,11 +5,15 @@ LL |     i
    |     ^ no implementation for `&i32 == Bar<'b, 'static>`
    |
    = help: the trait `PartialEq<Bar<'b, 'static>>` is not implemented for `&i32`
-   = help: the following implementations were found:
-             <i32 as PartialEq>
-             <f32 as PartialEq>
-             <f64 as PartialEq>
-             <i128 as PartialEq>
+   = help: the following other types implement trait `PartialEq<Rhs>`:
+             f32
+             f64
+             i128
+             i16
+             i32
+             i64
+             i8
+             isize
            and 6 others
 
 error[E0277]: can't compare `&i32` with `Foo<'static, 'b>`
@@ -19,11 +23,15 @@ LL |     i
    |     ^ no implementation for `&i32 == Foo<'static, 'b>`
    |
    = help: the trait `PartialEq<Foo<'static, 'b>>` is not implemented for `&i32`
-   = help: the following implementations were found:
-             <i32 as PartialEq>
-             <f32 as PartialEq>
-             <f64 as PartialEq>
-             <i128 as PartialEq>
+   = help: the following other types implement trait `PartialEq<Rhs>`:
+             f32
+             f64
+             i128
+             i16
+             i32
+             i64
+             i8
+             isize
            and 6 others
 
 error[E0277]: can't compare `&i32` with `Moo<'static, 'a>`
@@ -33,11 +41,15 @@ LL |     i
    |     ^ no implementation for `&i32 == Moo<'static, 'a>`
    |
    = help: the trait `PartialEq<Moo<'static, 'a>>` is not implemented for `&i32`
-   = help: the following implementations were found:
-             <i32 as PartialEq>
-             <f32 as PartialEq>
-             <f64 as PartialEq>
-             <i128 as PartialEq>
+   = help: the following other types implement trait `PartialEq<Rhs>`:
+             f32
+             f64
+             i128
+             i16
+             i32
+             i64
+             i8
+             isize
            and 6 others
 
 error: aborting due to 3 previous errors
diff --git a/src/test/ui/type-alias-impl-trait/self-referential.stderr b/src/test/ui/type-alias-impl-trait/self-referential.stderr
index 4384bc9b98a..2ebb15b8803 100644
--- a/src/test/ui/type-alias-impl-trait/self-referential.stderr
+++ b/src/test/ui/type-alias-impl-trait/self-referential.stderr
@@ -5,11 +5,15 @@ LL |     i
    |     ^ no implementation for `&i32 == Bar<'b, 'a>`
    |
    = help: the trait `PartialEq<Bar<'b, 'a>>` is not implemented for `&i32`
-   = help: the following implementations were found:
-             <i32 as PartialEq>
-             <f32 as PartialEq>
-             <f64 as PartialEq>
-             <i128 as PartialEq>
+   = help: the following other types implement trait `PartialEq<Rhs>`:
+             f32
+             f64
+             i128
+             i16
+             i32
+             i64
+             i8
+             isize
            and 6 others
 
 error[E0277]: can't compare `&i32` with `(i32, &i32)`
@@ -19,11 +23,15 @@ LL |     (42, i)
    |          ^ no implementation for `&i32 == (i32, &i32)`
    |
    = help: the trait `PartialEq<(i32, &i32)>` is not implemented for `&i32`
-   = help: the following implementations were found:
-             <i32 as PartialEq>
-             <f32 as PartialEq>
-             <f64 as PartialEq>
-             <i128 as PartialEq>
+   = help: the following other types implement trait `PartialEq<Rhs>`:
+             f32
+             f64
+             i128
+             i16
+             i32
+             i64
+             i8
+             isize
            and 6 others
 
 error[E0277]: can't compare `&i32` with `(i32, Moo<'b, 'a>::{opaque#0})`
@@ -33,11 +41,15 @@ LL |     (42, i)
    |          ^ no implementation for `&i32 == (i32, Moo<'b, 'a>::{opaque#0})`
    |
    = help: the trait `PartialEq<(i32, Moo<'b, 'a>::{opaque#0})>` is not implemented for `&i32`
-   = help: the following implementations were found:
-             <i32 as PartialEq>
-             <f32 as PartialEq>
-             <f64 as PartialEq>
-             <i128 as PartialEq>
+   = help: the following other types implement trait `PartialEq<Rhs>`:
+             f32
+             f64
+             i128
+             i16
+             i32
+             i64
+             i8
+             isize
            and 6 others
 
 error: aborting due to 3 previous errors