@@ -784,13 +784,20 @@ impl<'tcx> RegionInferenceContext<'tcx> {
784
784
/// is considered a *lower bound*. If possible, we will modify
785
785
/// the constraint to set it equal to one of the option regions.
786
786
/// 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.
787
791
#[ instrument( skip( self , member_constraint_index) , level = "debug" ) ]
788
792
fn apply_member_constraint (
789
793
& mut self ,
790
794
scc : ConstraintSccIndex ,
791
795
member_constraint_index : NllMemberConstraintIndex ,
792
796
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
+
794
801
// Create a mutable vector of the options. We'll try to winnow
795
802
// them down.
796
803
let mut choice_regions: Vec < ty:: RegionVid > = choice_regions. to_vec ( ) ;
@@ -805,10 +812,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
805
812
* c_r = self . scc_representatives [ scc] ;
806
813
}
807
814
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
+ }
812
820
debug_assert ! (
813
821
self . scc_values. placeholders_contained_in( scc) . next( ) . is_none( ) ,
814
822
"scc {:?} in a member constraint has placeholder value: {:?}" ,
@@ -832,7 +840,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
832
840
// free region that must outlive the member region `R0` (`UB:
833
841
// R0`). Therefore, we need only keep an option `O` if `UB: O`
834
842
// for all UB.
835
- self . compute_reverse_scc_graph ( ) ;
836
843
let universal_region_relations = & self . universal_region_relations ;
837
844
for ub in self . rev_scc_graph . as_ref ( ) . unwrap ( ) . upper_bounds ( scc) {
838
845
debug ! ( ?ub) ;
@@ -867,7 +874,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
867
874
}
868
875
} ) else {
869
876
debug ! ( "no unique minimum choice" ) ;
870
- return false ;
877
+ return ;
871
878
} ;
872
879
873
880
let min_choice_scc = self . constraint_sccs . scc ( min_choice) ;
@@ -878,10 +885,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
878
885
min_choice,
879
886
member_constraint_index,
880
887
} ) ;
881
-
882
- true
883
- } else {
884
- false
885
888
}
886
889
}
887
890
0 commit comments