@@ -191,10 +191,6 @@ pub struct RegionInferenceContext<'tcx> {
191
191
/// Type constraints that we check after solving.
192
192
type_tests : Vec < TypeTest < ' tcx > > ,
193
193
194
- /// Information about the universally quantified regions in scope
195
- /// on this function.
196
- universal_regions : Rc < UniversalRegions < ' tcx > > ,
197
-
198
194
/// Information about how the universally quantified regions in
199
195
/// scope on this function relate to one another.
200
196
universal_region_relations : Frozen < UniversalRegionRelations < ' tcx > > ,
@@ -399,7 +395,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
399
395
pub ( crate ) fn new (
400
396
infcx : & BorrowckInferCtxt < ' tcx > ,
401
397
var_infos : VarInfos ,
402
- universal_regions : Rc < UniversalRegions < ' tcx > > ,
403
398
placeholder_indices : Rc < PlaceholderIndices > ,
404
399
universal_region_relations : Frozen < UniversalRegionRelations < ' tcx > > ,
405
400
mut outlives_constraints : OutlivesConstraintSet < ' tcx > ,
@@ -409,7 +404,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
409
404
liveness_constraints : LivenessValues ,
410
405
elements : Rc < DenseLocationMap > ,
411
406
) -> Self {
412
- debug ! ( "universal_regions: {:#?}" , universal_regions) ;
407
+ let universal_regions = & universal_region_relations. universal_regions ;
408
+
409
+ debug ! ( "universal_regions: {:#?}" , universal_region_relations. universal_regions) ;
413
410
debug ! ( "outlives constraints: {:#?}" , outlives_constraints) ;
414
411
debug ! ( "placeholder_indices: {:#?}" , placeholder_indices) ;
415
412
debug ! ( "type tests: {:#?}" , type_tests) ;
@@ -453,7 +450,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
453
450
universe_causes,
454
451
scc_values,
455
452
type_tests,
456
- universal_regions,
457
453
universal_region_relations,
458
454
} ;
459
455
@@ -518,7 +514,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
518
514
fn init_free_and_bound_regions ( & mut self ) {
519
515
// Update the names (if any)
520
516
// This iterator has unstable order but we collect it all into an IndexVec
521
- for ( external_name, variable) in self . universal_regions . named_universal_regions ( ) {
517
+ for ( external_name, variable) in
518
+ self . universal_region_relations . universal_regions . named_universal_regions_iter ( )
519
+ {
522
520
debug ! (
523
521
"init_free_and_bound_regions: region {:?} has external name {:?}" ,
524
522
variable, external_name
@@ -562,7 +560,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
562
560
///
563
561
/// (Panics if `r` is not a registered universal region.)
564
562
pub ( crate ) fn to_region_vid ( & self , r : ty:: Region < ' tcx > ) -> RegionVid {
565
- self . universal_regions . to_region_vid ( r)
563
+ self . universal_regions ( ) . to_region_vid ( r)
566
564
}
567
565
568
566
/// Returns an iterator over all the outlives constraints.
@@ -574,7 +572,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
574
572
575
573
/// Adds annotations for `#[rustc_regions]`; see `UniversalRegions::annotate`.
576
574
pub ( crate ) fn annotate ( & self , tcx : TyCtxt < ' tcx > , err : & mut Diag < ' _ , ( ) > ) {
577
- self . universal_regions . annotate ( tcx, err)
575
+ self . universal_regions ( ) . annotate ( tcx, err)
578
576
}
579
577
580
578
/// Returns `true` if the region `r` contains the point `p`.
@@ -686,7 +684,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
686
684
if outlives_requirements. is_empty ( ) {
687
685
( None , errors_buffer)
688
686
} else {
689
- let num_external_vids = self . universal_regions . num_global_and_external_regions ( ) ;
687
+ let num_external_vids = self . universal_regions ( ) . num_global_and_external_regions ( ) ;
690
688
(
691
689
Some ( ClosureRegionRequirements { num_external_vids, outlives_requirements } ) ,
692
690
errors_buffer,
@@ -989,7 +987,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
989
987
// always be in the root universe.
990
988
if let Some ( p) = self . scc_values . placeholders_contained_in ( r_scc) . next ( ) {
991
989
debug ! ( "encountered placeholder in higher universe: {:?}, requiring 'static" , p) ;
992
- let static_r = self . universal_regions . fr_static ;
990
+ let static_r = self . universal_regions ( ) . fr_static ;
993
991
propagated_outlives_requirements. push ( ClosureOutlivesRequirement {
994
992
subject,
995
993
outlived_free_region : static_r,
@@ -1032,8 +1030,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1032
1030
// avoid potential non-determinism we approximate this by requiring
1033
1031
// T: '1 and T: '2.
1034
1032
for upper_bound in non_local_ub {
1035
- debug_assert ! ( self . universal_regions. is_universal_region( upper_bound) ) ;
1036
- debug_assert ! ( !self . universal_regions. is_local_free_region( upper_bound) ) ;
1033
+ debug_assert ! ( self . universal_regions( ) . is_universal_region( upper_bound) ) ;
1034
+ debug_assert ! ( !self . universal_regions( ) . is_local_free_region( upper_bound) ) ;
1037
1035
1038
1036
let requirement = ClosureOutlivesRequirement {
1039
1037
subject,
@@ -1101,7 +1099,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1101
1099
// To do so, we simply check every candidate `u_r` for equality.
1102
1100
self . scc_values
1103
1101
. universal_regions_outlived_by ( r_scc)
1104
- . filter ( |& u_r| !self . universal_regions . is_local_free_region ( u_r) )
1102
+ . filter ( |& u_r| !self . universal_regions ( ) . is_local_free_region ( u_r) )
1105
1103
. find ( |& u_r| self . eval_equal ( u_r, r_vid) )
1106
1104
. map ( |u_r| ty:: Region :: new_var ( tcx, u_r) )
1107
1105
// In case we could not find a named region to map to,
@@ -1139,9 +1137,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1139
1137
1140
1138
// Find the smallest universal region that contains all other
1141
1139
// universal regions within `region`.
1142
- let mut lub = self . universal_regions . fr_fn_body ;
1140
+ let mut lub = self . universal_regions ( ) . fr_fn_body ;
1143
1141
let r_scc = self . constraint_sccs . scc ( r) ;
1144
- let static_r = self . universal_regions . fr_static ;
1142
+ let static_r = self . universal_regions ( ) . fr_static ;
1145
1143
for ur in self . scc_values . universal_regions_outlived_by ( r_scc) {
1146
1144
let new_lub = self . universal_region_relations . postdom_upper_bound ( lub, ur) ;
1147
1145
debug ! ( ?ur, ?lub, ?new_lub) ;
@@ -1288,12 +1286,12 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1288
1286
debug ! (
1289
1287
"sup_region's value = {:?} universal={:?}" ,
1290
1288
self . region_value_str( sup_region) ,
1291
- self . universal_regions. is_universal_region( sup_region) ,
1289
+ self . universal_regions( ) . is_universal_region( sup_region) ,
1292
1290
) ;
1293
1291
debug ! (
1294
1292
"sub_region's value = {:?} universal={:?}" ,
1295
1293
self . region_value_str( sub_region) ,
1296
- self . universal_regions. is_universal_region( sub_region) ,
1294
+ self . universal_regions( ) . is_universal_region( sub_region) ,
1297
1295
) ;
1298
1296
1299
1297
let sub_region_scc = self . constraint_sccs . scc ( sub_region) ;
@@ -1308,7 +1306,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1308
1306
by super `{sup_region_scc:?}`, promoting to static",
1309
1307
) ;
1310
1308
1311
- return self . eval_outlives ( sup_region, self . universal_regions . fr_static ) ;
1309
+ return self . eval_outlives ( sup_region, self . universal_regions ( ) . fr_static ) ;
1312
1310
}
1313
1311
1314
1312
// Both the `sub_region` and `sup_region` consist of the union
@@ -1332,7 +1330,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1332
1330
// Now we have to compare all the points in the sub region and make
1333
1331
// sure they exist in the sup region.
1334
1332
1335
- if self . universal_regions . is_universal_region ( sup_region) {
1333
+ if self . universal_regions ( ) . is_universal_region ( sup_region) {
1336
1334
// Micro-opt: universal regions contain all points.
1337
1335
debug ! ( "super is universal and hence contains all points" ) ;
1338
1336
return true ;
@@ -1736,7 +1734,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1736
1734
debug ! ( "provides_universal_region(r={:?}, fr1={:?}, fr2={:?})" , r, fr1, fr2) ;
1737
1735
let result = {
1738
1736
r == fr2 || {
1739
- fr2 == self . universal_regions . fr_static && self . cannot_name_placeholder ( fr1, r)
1737
+ fr2 == self . universal_regions ( ) . fr_static && self . cannot_name_placeholder ( fr1, r)
1740
1738
}
1741
1739
} ;
1742
1740
debug ! ( "provides_universal_region: result = {:?}" , result) ;
@@ -1837,7 +1835,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1837
1835
1838
1836
// A constraint like `'r: 'x` can come from our constraint
1839
1837
// graph.
1840
- let fr_static = self . universal_regions . fr_static ;
1838
+ let fr_static = self . universal_regions ( ) . fr_static ;
1841
1839
let outgoing_edges_from_graph =
1842
1840
self . constraint_graph . outgoing_edges ( r, & self . constraints , fr_static) ;
1843
1841
@@ -1952,7 +1950,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1952
1950
}
1953
1951
1954
1952
pub ( crate ) fn universal_regions ( & self ) -> & UniversalRegions < ' tcx > {
1955
- self . universal_regions . as_ref ( )
1953
+ & self . universal_region_relations . universal_regions
1956
1954
}
1957
1955
1958
1956
/// Tries to find the best constraint to blame for the fact that
@@ -2212,7 +2210,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
2212
2210
2213
2211
/// Access to the region graph, built from the outlives constraints.
2214
2212
pub ( crate ) fn region_graph ( & self ) -> RegionGraph < ' _ , ' tcx , graph:: Normal > {
2215
- self . constraint_graph . region_graph ( & self . constraints , self . universal_regions . fr_static )
2213
+ self . constraint_graph . region_graph ( & self . constraints , self . universal_regions ( ) . fr_static )
2216
2214
}
2217
2215
2218
2216
/// Returns whether the given region is considered live at all points: whether it is a
0 commit comments