@@ -611,8 +611,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
611
611
#[ instrument( skip( self , _body) , level = "debug" ) ]
612
612
fn propagate_constraints ( & mut self , _body : & Body < ' tcx > ) {
613
613
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( ) ;
616
615
constraints
617
616
. into_iter( )
618
617
. map( |c| ( c, self . constraint_sccs. scc( c. sup) , self . constraint_sccs. scc( c. sub) ) )
@@ -2006,7 +2005,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
2006
2005
. unwrap_or_else ( || ObligationCauseCode :: MiscObligation ) ;
2007
2006
2008
2007
// 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
2010
2009
. iter ( )
2011
2010
. map ( |constraint| {
2012
2011
if constraint. category == ConstraintCategory :: ClosureBounds {
@@ -2130,7 +2129,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
2130
2129
) ;
2131
2130
2132
2131
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 ) {
2134
2133
if matches ! ( categorized_path[ i] . category, ConstraintCategory :: Return ( _) )
2135
2134
&& next. category == ConstraintCategory :: OpaqueType
2136
2135
{
@@ -2151,22 +2150,19 @@ impl<'tcx> RegionInferenceContext<'tcx> {
2151
2150
} ) ;
2152
2151
2153
2152
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 =
2155
2155
ConstraintCategory :: Return ( ReturnConstraint :: ClosureUpvar ( field) ) ;
2156
+ let updated_categorized_path: indexmap:: IndexSet < _ > =
2157
+ blame_vec. into_iter ( ) . collect ( ) ;
2158
+ categorized_path = updated_categorized_path
2156
2159
}
2157
2160
}
2158
2161
2159
2162
return categorized_path[ i] . clone ( ) ;
2160
2163
}
2161
2164
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 ( )
2170
2166
}
2171
2167
2172
2168
crate fn universe_info ( & self , universe : ty:: UniverseIndex ) -> UniverseInfo < ' tcx > {
@@ -2266,7 +2262,7 @@ impl<'tcx> ClosureRegionRequirementsExt<'tcx> for ClosureRegionRequirements<'tcx
2266
2262
}
2267
2263
}
2268
2264
2269
- #[ derive( Clone , Debug ) ]
2265
+ #[ derive( Clone , Debug , Hash , PartialEq , Eq ) ]
2270
2266
pub struct BlameConstraint < ' tcx > {
2271
2267
pub category : ConstraintCategory ,
2272
2268
pub from_closure : bool ,
0 commit comments