@@ -611,8 +611,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
611611 #[ instrument( skip( self , _body) , level = "debug" ) ]
612612 fn propagate_constraints ( & mut self , _body : & Body < ' tcx > ) {
613613 debug ! ( "constraints={:#?}" , {
614- let mut constraints: Vec <_> = self . constraints. outlives( ) . iter( ) . collect( ) ;
615- constraints. sort( ) ;
614+ let constraints: indexmap:: IndexSet <_> = self . constraints. outlives( ) . iter( ) . collect( ) ;
616615 constraints
617616 . into_iter( )
618617 . map( |c| ( c, self . constraint_sccs. scc( c. sup) , self . constraint_sccs. scc( c. sub) ) )
@@ -2006,7 +2005,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
20062005 . unwrap_or_else ( || ObligationCauseCode :: MiscObligation ) ;
20072006
20082007 // Classify each of the constraints along the path.
2009- let mut categorized_path: Vec < BlameConstraint < ' tcx > > = path
2008+ let mut categorized_path: indexmap :: IndexSet < BlameConstraint < ' tcx > > = path
20102009 . iter ( )
20112010 . map ( |constraint| {
20122011 if constraint. category == ConstraintCategory :: ClosureBounds {
@@ -2130,7 +2129,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
21302129 ) ;
21312130
21322131 if let Some ( i) = best_choice {
2133- if let Some ( next) = categorized_path. get ( i + 1 ) {
2132+ if let Some ( next) = categorized_path. get_index ( i + 1 ) {
21342133 if matches ! ( categorized_path[ i] . category, ConstraintCategory :: Return ( _) )
21352134 && next. category == ConstraintCategory :: OpaqueType
21362135 {
@@ -2151,22 +2150,19 @@ impl<'tcx> RegionInferenceContext<'tcx> {
21512150 } ) ;
21522151
21532152 if let Some ( field) = field {
2154- categorized_path[ i] . category =
2153+ let mut blame_vec: Vec < _ > = categorized_path. into_iter ( ) . collect ( ) ;
2154+ blame_vec[ i] . category =
21552155 ConstraintCategory :: Return ( ReturnConstraint :: ClosureUpvar ( field) ) ;
2156+ let updated_categorized_path: indexmap:: IndexSet < _ > =
2157+ blame_vec. into_iter ( ) . collect ( ) ;
2158+ categorized_path = updated_categorized_path
21562159 }
21572160 }
21582161
21592162 return categorized_path[ i] . clone ( ) ;
21602163 }
21612164
2162- // If that search fails, that is.. unusual. Maybe everything
2163- // is in the same SCC or something. In that case, find what
2164- // appears to be the most interesting point to report to the
2165- // user via an even more ad-hoc guess.
2166- categorized_path. sort_by ( |p0, p1| p0. category . cmp ( & p1. category ) ) ;
2167- debug ! ( "best_blame_constraint: sorted_path={:#?}" , categorized_path) ;
2168-
2169- categorized_path. remove ( 0 )
2165+ categorized_path. shift_remove_index ( 0 ) . unwrap ( )
21702166 }
21712167
21722168 crate fn universe_info ( & self , universe : ty:: UniverseIndex ) -> UniverseInfo < ' tcx > {
@@ -2266,7 +2262,7 @@ impl<'tcx> ClosureRegionRequirementsExt<'tcx> for ClosureRegionRequirements<'tcx
22662262 }
22672263}
22682264
2269- #[ derive( Clone , Debug ) ]
2265+ #[ derive( Clone , Debug , Hash , PartialEq , Eq ) ]
22702266pub struct BlameConstraint < ' tcx > {
22712267 pub category : ConstraintCategory ,
22722268 pub from_closure : bool ,
0 commit comments