@@ -2,7 +2,7 @@ use rustc_data_structures::fx::FxHashSet;
2
2
use rustc_data_structures:: sync:: Lock ;
3
3
use rustc_span:: Symbol ;
4
4
use rustc_target:: abi:: { Align , Size } ;
5
- use std:: cmp:: { self , Ordering } ;
5
+ use std:: cmp;
6
6
7
7
#[ derive( Clone , PartialEq , Eq , Hash , Debug ) ]
8
8
pub struct VariantInfo {
@@ -87,7 +87,7 @@ impl CodeStats {
87
87
// Except for Generators, whose variants are already sorted according to
88
88
// their yield points in `variant_info_for_generator`.
89
89
if kind != DataTypeKind :: Generator {
90
- variants. sort_by ( |info1 , info2| info2 . size . cmp ( & info1 . size ) ) ;
90
+ variants. sort_by_key ( |info| cmp:: Reverse ( info . size ) ) ;
91
91
}
92
92
let info = TypeSizeInfo {
93
93
kind,
@@ -107,13 +107,7 @@ impl CodeStats {
107
107
108
108
// Primary sort: large-to-small.
109
109
// Secondary sort: description (dictionary order)
110
- sorted. sort_by ( |info1, info2| {
111
- // (reversing cmp order to get large-to-small ordering)
112
- match info2. overall_size . cmp ( & info1. overall_size ) {
113
- Ordering :: Equal => info1. type_description . cmp ( & info2. type_description ) ,
114
- other => other,
115
- }
116
- } ) ;
110
+ sorted. sort_by_key ( |info| ( cmp:: Reverse ( info. overall_size ) , & info. type_description ) ) ;
117
111
118
112
for info in sorted {
119
113
let TypeSizeInfo { type_description, overall_size, align, kind, variants, .. } = info;
0 commit comments