Skip to content

Commit d4a6e73

Browse files
committed
Use sort_by_cached_key when key the function is not trivial/free
1 parent 45205f2 commit d4a6e73

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/librustc/middle/resolve_lifetime.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
15731573
.collect();
15741574

15751575
// ensure that we issue lints in a repeatable order
1576-
def_ids.sort_by_key(|&def_id| self.tcx.def_path_hash(def_id));
1576+
def_ids.sort_by_cached_key(|&def_id| self.tcx.def_path_hash(def_id));
15771577

15781578
for def_id in def_ids {
15791579
debug!(

src/librustc/traits/object_safety.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
409409
.collect::<Vec<_>>();
410410

411411
// existential predicates need to be in a specific order
412-
associated_types.sort_by_key(|item| self.def_path_hash(item.def_id));
412+
associated_types.sort_by_cached_key(|item| self.def_path_hash(item.def_id));
413413

414414
let projection_predicates = associated_types.into_iter().map(|item| {
415415
ty::ExistentialPredicate::Projection(ty::ExistentialProjection {

src/librustc_mir/monomorphize/partitioning.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ fn collect_and_partition_mono_items<'a, 'tcx>(
985985
output.push_str(" @@");
986986
let mut empty = Vec::new();
987987
let cgus = item_to_cgus.get_mut(i).unwrap_or(&mut empty);
988-
cgus.as_mut_slice().sort_by_key(|&(ref name, _)| name.clone());
988+
cgus.as_mut_slice().sort_by_cached_key(|&(ref name, _)| name.clone());
989989
cgus.dedup();
990990
for &(ref cgu_name, (linkage, _)) in cgus.iter() {
991991
output.push_str(" ");

0 commit comments

Comments
 (0)