@@ -2,7 +2,7 @@ use rustc_data_structures::fx::FxHashSet;
22use rustc_data_structures:: sync:: Lock ;
33use rustc_span:: Symbol ;
44use rustc_target:: abi:: { Align , Size } ;
5- use std:: cmp:: { self , Ordering } ;
5+ use std:: cmp;
66
77#[ derive( Clone , PartialEq , Eq , Hash , Debug ) ]
88pub struct VariantInfo {
@@ -87,7 +87,7 @@ impl CodeStats {
8787 // Except for Generators, whose variants are already sorted according to
8888 // their yield points in `variant_info_for_generator`.
8989 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 ) ) ;
9191 }
9292 let info = TypeSizeInfo {
9393 kind,
@@ -107,13 +107,7 @@ impl CodeStats {
107107
108108 // Primary sort: large-to-small.
109109 // 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 ) ) ;
117111
118112 for info in sorted {
119113 let TypeSizeInfo { type_description, overall_size, align, kind, variants, .. } = info;
0 commit comments