@@ -661,28 +661,33 @@ impl<'tcx> RegionInferenceContext<'tcx> {
661661 test : _,
662662 } = type_test;
663663
664+
664665 let generic_ty = generic_kind. to_ty ( tcx) ;
665666 let subject = match self . try_promote_type_test_subject ( infcx, generic_ty) {
666667 Some ( s) => s,
667668 None => return false ,
668669 } ;
669670
670- // Find some bounding subject-region R+ that is a super-region
671- // of the existing subject-region R. This should be a non-local, universal
672- // region, which ensures it can be encoded in a `ClosureOutlivesRequirement`.
673- let lower_bound_plus = self . non_local_universal_upper_bound ( * lower_bound) ;
674- assert ! ( self . universal_regions. is_universal_region( lower_bound_plus) ) ;
675- assert ! (
676- !self
671+ // For each region outlived by lower_bound find a non-local,
672+ // universal region (it may be the same region) and add it to
673+ // `ClosureOutlivesRequirement`.
674+ let r_scc = self . constraint_sccs . scc ( * lower_bound) ;
675+ for ur in self . scc_values . universal_regions_outlived_by ( r_scc) {
676+ let non_local_ub = self . universal_region_relations . non_local_upper_bound ( ur) ;
677+
678+ assert ! ( self . universal_regions. is_universal_region( non_local_ub) ) ;
679+ assert ! (
680+ !self
677681 . universal_regions
678- . is_local_free_region( lower_bound_plus )
679- ) ;
682+ . is_local_free_region( non_local_ub )
683+ ) ;
680684
681- propagated_outlives_requirements. push ( ClosureOutlivesRequirement {
682- subject,
683- outlived_free_region : lower_bound_plus,
684- blame_span : locations. span ( mir) ,
685- } ) ;
685+ propagated_outlives_requirements. push ( ClosureOutlivesRequirement {
686+ subject,
687+ outlived_free_region : non_local_ub,
688+ blame_span : locations. span ( mir) ,
689+ } ) ;
690+ }
686691 true
687692 }
688693
0 commit comments