1
Fork 0

Auto merge of #76541 - matthiaskrgr:unstable_sort, r=davidtwco

use sort_unstable to sort primitive types

It's not important to retain original order if we have &[1, 1, 2, 3] for example.

clippy::stable_sort_primitive
This commit is contained in:
bors 2020-09-14 21:43:17 +00:00
commit 9b4154193e
6 changed files with 16 additions and 9 deletions

View file

@ -4285,11 +4285,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
None
}
})
.collect::<Vec<_>>();
.collect::<Vec<usize>>();
// Both checked and coerced types could have matched, thus we need to remove
// duplicates.
referenced_in.sort();
// We sort primitive type usize here and can use unstable sort
referenced_in.sort_unstable();
referenced_in.dedup();
if let (Some(ref_in), None) = (referenced_in.pop(), referenced_in.pop()) {