Skip to content

Commit b72d663

Browse files
committed
fix trait implementations sort order
1 parent 8dac72b commit b72d663

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2216,7 +2216,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
22162216
cand
22172217
})
22182218
.collect();
2219-
impl_candidates.sort_by_key(|cand| (cand.similarity, cand.trait_ref.to_string()));
2219+
impl_candidates.sort_by_key(|cand| (cand.similarity, cand.trait_ref.args.len()));
22202220
let mut impl_candidates: Vec<_> =
22212221
impl_candidates.into_iter().map(|cand| cand.trait_ref).collect();
22222222
impl_candidates.dedup();

tests/ui/suggestions/issue-71394-no-from-impl.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ LL | let _: &[i8] = data.into();
55
| ^^^^ the trait `From<&[u8]>` is not implemented for `&[i8]`
66
|
77
= help: the following other types implement trait `From<T>`:
8-
`[T; 10]` implements `From<(T, T, T, T, T, T, T, T, T, T)>`
9-
`[T; 11]` implements `From<(T, T, T, T, T, T, T, T, T, T, T)>`
10-
`[T; 12]` implements `From<(T, T, T, T, T, T, T, T, T, T, T, T)>`
118
`[T; 1]` implements `From<(T,)>`
129
`[T; 2]` implements `From<(T, T)>`
1310
`[T; 3]` implements `From<(T, T, T)>`
1411
`[T; 4]` implements `From<(T, T, T, T)>`
1512
`[T; 5]` implements `From<(T, T, T, T, T)>`
13+
`[T; 6]` implements `From<(T, T, T, T, T, T)>`
14+
`[T; 7]` implements `From<(T, T, T, T, T, T, T)>`
15+
`[T; 8]` implements `From<(T, T, T, T, T, T, T, T)>`
1616
and 6 others
1717
= note: required for `&[u8]` to implement `Into<&[i8]>`
1818

0 commit comments

Comments
 (0)