@@ -403,19 +403,22 @@ fn try_extract_error_from_region_constraints<'tcx>(
403403 mut region_var_origin : impl FnMut ( RegionVid ) -> RegionVariableOrigin ,
404404 mut universe_of_region : impl FnMut ( RegionVid ) -> UniverseIndex ,
405405) -> Option < DiagnosticBuilder < ' tcx , ErrorGuaranteed > > {
406- let ( sub_region, cause) =
407- region_constraints. constraints . iter ( ) . find_map ( |( constraint, cause) | {
406+ let ( _, _, sub_region, cause) = region_constraints
407+ . constraints
408+ . iter ( )
409+ . filter_map ( |( constraint, cause) | {
408410 match * constraint {
409411 Constraint :: RegSubReg ( sub, sup) if sup == placeholder_region && sup != sub => {
410- Some ( ( sub, cause. clone ( ) ) )
412+ Some ( ( 1u8 , None , sub, cause. clone ( ) ) )
411413 }
412414 // FIXME: Should this check the universe of the var?
413415 Constraint :: VarSubReg ( vid, sup) if sup == placeholder_region => {
414- Some ( ( infcx. tcx . mk_region ( ty:: ReVar ( vid) ) , cause. clone ( ) ) )
416+ Some ( ( 0u8 , Some ( vid ) , infcx. tcx . mk_region ( ty:: ReVar ( vid) ) , cause. clone ( ) ) )
415417 }
416418 _ => None ,
417419 }
418- } ) ?;
420+ } )
421+ . min_by_key ( |( discr, vid, ..) | ( * discr, * vid) ) ?;
419422
420423 debug ! ( ?sub_region, "cause = {:#?}" , cause) ;
421424 let error = match ( error_region, * sub_region) {
0 commit comments