@@ -85,7 +85,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8585/// Intermediate format to store the hir_id pointing to the use that resulted in the
8686/// corresponding place being captured and a String which contains the captured value's
8787/// name (i.e: a.b.c)
88- #[ derive( Clone , Debug , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
88+ #[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
8989enum UpvarMigrationInfo {
9090 /// We previously captured all of `x`, but now we capture some sub-path.
9191 CapturingPrecise { source_expr : Option < HirId > , var_name : String } ,
@@ -1396,14 +1396,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13961396 FxIndexSet :: default ( )
13971397 } ;
13981398
1399- // Combine all the captures responsible for needing migrations into one HashSet
1399+ // Combine all the captures responsible for needing migrations into one IndexSet
14001400 let mut capture_diagnostic = drop_reorder_diagnostic. clone ( ) ;
14011401 for key in auto_trait_diagnostic. keys ( ) {
14021402 capture_diagnostic. insert ( key. clone ( ) ) ;
14031403 }
14041404
14051405 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+ } ) ;
14071412 for captures_info in capture_diagnostic {
14081413 // Get the auto trait reasons of why migration is needed because of that capture, if there are any
14091414 let capture_trait_reasons =
0 commit comments