Skip to content

Commit a8839c3

Browse files
committed
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.
1 parent cd6c574 commit a8839c3

File tree

1 file changed

+2
-2
lines changed
  • compiler/rustc_borrowck/src/region_infer

1 file changed

+2
-2
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ fn sccs_info<'cx, 'tcx>(
255255
let var_to_origin = infcx.reg_var_to_origin.borrow();
256256

257257
let mut var_to_origin_sorted = var_to_origin.clone().into_iter().collect::<Vec<_>>();
258-
var_to_origin_sorted.sort_by(|a, b| a.0.cmp(&b.0));
258+
var_to_origin_sorted.sort_by_key(|vto| vto.0);
259259
let mut debug_str = "region variables to origins:\n".to_string();
260260
for (reg_var, origin) in var_to_origin_sorted.into_iter() {
261261
debug_str.push_str(&format!("{:?}: {:?}\n", reg_var, origin));
@@ -2216,7 +2216,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
22162216
// is in the same SCC or something. In that case, find what
22172217
// appears to be the most interesting point to report to the
22182218
// user via an even more ad-hoc guess.
2219-
categorized_path.sort_by(|p0, p1| p0.category.cmp(&p1.category));
2219+
categorized_path.sort_by_key(|p| p.category);
22202220
debug!("sorted_path={:#?}", categorized_path);
22212221

22222222
(categorized_path.remove(0), extra_info)

0 commit comments

Comments
 (0)