From a8839c3de79740ad76bad4439a5cc5169bf68d53 Mon Sep 17 00:00:00 2001 From: est31 Date: Thu, 16 Mar 2023 13:00:49 +0100 Subject: [PATCH] Use sort_by_key instead of sort_by I went over the cases where sort_by is used and in these two, one can use sort_by_key instead. --- compiler/rustc_borrowck/src/region_infer/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index 905d8c42b28bc..dbf15a3e05fa9 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -255,7 +255,7 @@ fn sccs_info<'cx, 'tcx>( let var_to_origin = infcx.reg_var_to_origin.borrow(); let mut var_to_origin_sorted = var_to_origin.clone().into_iter().collect::>(); - var_to_origin_sorted.sort_by(|a, b| a.0.cmp(&b.0)); + var_to_origin_sorted.sort_by_key(|vto| vto.0); let mut debug_str = "region variables to origins:\n".to_string(); for (reg_var, origin) in var_to_origin_sorted.into_iter() { debug_str.push_str(&format!("{:?}: {:?}\n", reg_var, origin)); @@ -2216,7 +2216,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // is in the same SCC or something. In that case, find what // appears to be the most interesting point to report to the // user via an even more ad-hoc guess. - categorized_path.sort_by(|p0, p1| p0.category.cmp(&p1.category)); + categorized_path.sort_by_key(|p| p.category); debug!("sorted_path={:#?}", categorized_path); (categorized_path.remove(0), extra_info)