@@ -85,7 +85,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
85
85
/// Intermediate format to store the hir_id pointing to the use that resulted in the
86
86
/// corresponding place being captured and a String which contains the captured value's
87
87
/// name (i.e: a.b.c)
88
- #[ derive( Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
88
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
89
89
enum UpvarMigrationInfo {
90
90
/// We previously captured all of `x`, but now we capture some sub-path.
91
91
CapturingPrecise { source_expr : Option < HirId > , var_name : String } ,
@@ -1396,14 +1396,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
1396
1396
FxIndexSet :: default ( )
1397
1397
} ;
1398
1398
1399
- // Combine all the captures responsible for needing migrations into one HashSet
1399
+ // Combine all the captures responsible for needing migrations into one IndexSet
1400
1400
let mut capture_diagnostic = drop_reorder_diagnostic. clone ( ) ;
1401
1401
for key in auto_trait_diagnostic. keys ( ) {
1402
1402
capture_diagnostic. insert ( key. clone ( ) ) ;
1403
1403
}
1404
1404
1405
1405
let mut capture_diagnostic = capture_diagnostic. into_iter ( ) . collect :: < Vec < _ > > ( ) ;
1406
- capture_diagnostic. sort ( ) ;
1406
+ capture_diagnostic. sort_by_cached_key ( |info| match info {
1407
+ UpvarMigrationInfo :: CapturingPrecise { source_expr : _, var_name } => {
1408
+ ( 0 , Some ( var_name. clone ( ) ) )
1409
+ }
1410
+ UpvarMigrationInfo :: CapturingNothing { use_span : _ } => ( 1 , None ) ,
1411
+ } ) ;
1407
1412
for captures_info in capture_diagnostic {
1408
1413
// Get the auto trait reasons of why migration is needed because of that capture, if there are any
1409
1414
let capture_trait_reasons =
0 commit comments