@@ -784,13 +784,20 @@ impl<'tcx> RegionInferenceContext<'tcx> {
784784 /// is considered a *lower bound*. If possible, we will modify
785785 /// the constraint to set it equal to one of the option regions.
786786 /// If we make any changes, returns true, else false.
787+ ///
788+ /// This function only adds the member constraints to the region graph,
789+ /// it does not check them. They are later checked in
790+ /// `check_member_constraints` after the region graph has been computed.
787791 #[ instrument( skip( self , member_constraint_index) , level = "debug" ) ]
788792 fn apply_member_constraint (
789793 & mut self ,
790794 scc : ConstraintSccIndex ,
791795 member_constraint_index : NllMemberConstraintIndex ,
792796 choice_regions : & [ ty:: RegionVid ] ,
793- ) -> bool {
797+ ) {
798+ // Lazily compute the reverse graph, we'll need it later.
799+ self . compute_reverse_scc_graph ( ) ;
800+
794801 // Create a mutable vector of the options. We'll try to winnow
795802 // them down.
796803 let mut choice_regions: Vec < ty:: RegionVid > = choice_regions. to_vec ( ) ;
@@ -805,10 +812,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
805812 * c_r = self . scc_representatives [ scc] ;
806813 }
807814
808- // The 'member region' in a member constraint is part of the
809- // hidden type, which must be in the root universe. Therefore,
810- // it cannot have any placeholders in its value.
811- assert ! ( self . scc_universes[ scc] == ty:: UniverseIndex :: ROOT ) ;
815+ // If the member region lives in a higher universe, we currently choose
816+ // the most conservative option by leaving it unchanged.
817+ if self . scc_universes [ scc] != ty:: UniverseIndex :: ROOT {
818+ return ;
819+ }
812820 debug_assert ! (
813821 self . scc_values. placeholders_contained_in( scc) . next( ) . is_none( ) ,
814822 "scc {:?} in a member constraint has placeholder value: {:?}" ,
@@ -832,7 +840,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
832840 // free region that must outlive the member region `R0` (`UB:
833841 // R0`). Therefore, we need only keep an option `O` if `UB: O`
834842 // for all UB.
835- self . compute_reverse_scc_graph ( ) ;
836843 let universal_region_relations = & self . universal_region_relations ;
837844 for ub in self . rev_scc_graph . as_ref ( ) . unwrap ( ) . upper_bounds ( scc) {
838845 debug ! ( ?ub) ;
@@ -867,7 +874,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
867874 }
868875 } ) else {
869876 debug ! ( "no unique minimum choice" ) ;
870- return false ;
877+ return ;
871878 } ;
872879
873880 let min_choice_scc = self . constraint_sccs . scc ( min_choice) ;
@@ -878,10 +885,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
878885 min_choice,
879886 member_constraint_index,
880887 } ) ;
881-
882- true
883- } else {
884- false
885888 }
886889 }
887890
0 commit comments