diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index c92dfa24f85ed..caa9eb2b10247 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -2216,7 +2216,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { cand }) .collect(); - impl_candidates.sort_by_key(|cand| (cand.similarity, cand.trait_ref.to_string())); + impl_candidates.sort_by_key(|cand| (cand.similarity, cand.trait_ref.args.len())); let mut impl_candidates: Vec<_> = impl_candidates.into_iter().map(|cand| cand.trait_ref).collect(); impl_candidates.dedup(); diff --git a/tests/ui/suggestions/issue-71394-no-from-impl.stderr b/tests/ui/suggestions/issue-71394-no-from-impl.stderr index 31f8f1d455aba..9e068c311ae05 100644 --- a/tests/ui/suggestions/issue-71394-no-from-impl.stderr +++ b/tests/ui/suggestions/issue-71394-no-from-impl.stderr @@ -5,14 +5,14 @@ LL | let _: &[i8] = data.into(); | ^^^^ the trait `From<&[u8]>` is not implemented for `&[i8]` | = help: the following other types implement trait `From`: - `[T; 10]` implements `From<(T, T, T, T, T, T, T, T, T, T)>` - `[T; 11]` implements `From<(T, T, T, T, T, T, T, T, T, T, T)>` - `[T; 12]` implements `From<(T, T, T, T, T, T, T, T, T, T, T, T)>` `[T; 1]` implements `From<(T,)>` `[T; 2]` implements `From<(T, T)>` `[T; 3]` implements `From<(T, T, T)>` `[T; 4]` implements `From<(T, T, T, T)>` `[T; 5]` implements `From<(T, T, T, T, T)>` + `[T; 6]` implements `From<(T, T, T, T, T, T)>` + `[T; 7]` implements `From<(T, T, T, T, T, T, T)>` + `[T; 8]` implements `From<(T, T, T, T, T, T, T, T)>` and 6 others = note: required for `&[u8]` to implement `Into<&[i8]>`