diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 34b73947e3d..12f522d1adc 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -1185,7 +1185,7 @@ pub fn report_no_match_method_error( }) .collect::>(); if !inherent_impls_candidate.is_empty() { - inherent_impls_candidate.sort(); + inherent_impls_candidate.sort_by_key(|id| self.tcx.def_path_str(id)); inherent_impls_candidate.dedup(); // number of types to show at most diff --git a/tests/ui/methods/method-not-found-generic-arg-elision.stderr b/tests/ui/methods/method-not-found-generic-arg-elision.stderr index b97688d3868..a665500fd9e 100644 --- a/tests/ui/methods/method-not-found-generic-arg-elision.stderr +++ b/tests/ui/methods/method-not-found-generic-arg-elision.stderr @@ -35,10 +35,10 @@ LL | wrapper.method(); | ^^^^^^ method not found in `Wrapper` | = note: the method was found for - - `Wrapper` - `Wrapper` - `Wrapper` - `Wrapper` + - `Wrapper` and 2 more types error[E0599]: no method named `other` found for struct `Wrapper` in the current scope @@ -60,9 +60,9 @@ LL | wrapper.method(); | ^^^^^^ method not found in `Wrapper2<'_, bool, 3>` | = note: the method was found for - - `Wrapper2<'a, i8, C>` - `Wrapper2<'a, i16, C>` - `Wrapper2<'a, i32, C>` + - `Wrapper2<'a, i8, C>` error[E0599]: no method named `other` found for struct `Wrapper2` in the current scope --> $DIR/method-not-found-generic-arg-elision.rs:98:13