@@ -29,18 +29,6 @@ use syntax::ast;
29
29
crate struct UniversalRegionRelations < ' tcx > {
30
30
universal_regions : Rc < UniversalRegions < ' tcx > > ,
31
31
32
- /// Each RBP `('a, GK)` indicates that `GK: 'a` can be assumed to
33
- /// be true. These encode relationships like `T: 'a` that are
34
- /// added via implicit bounds.
35
- ///
36
- /// Each region here is guaranteed to be a key in the `indices`
37
- /// map. We use the "original" regions (i.e., the keys from the
38
- /// map, and not the values) because the code in
39
- /// `process_registered_region_obligations` has some special-cased
40
- /// logic expecting to see (e.g.) `ReStatic`, and if we supplied
41
- /// our special inference variable there, we would mess that up.
42
- crate region_bound_pairs : Vec < ( ty:: Region < ' tcx > , GenericKind < ' tcx > ) > ,
43
-
44
32
/// Stores the outlives relations that are known to hold from the
45
33
/// implied bounds, in-scope where clauses, and that sort of
46
34
/// thing.
@@ -53,6 +41,18 @@ crate struct UniversalRegionRelations<'tcx> {
53
41
inverse_outlives : TransitiveRelation < RegionVid > ,
54
42
}
55
43
44
+ /// Each RBP `('a, GK)` indicates that `GK: 'a` can be assumed to
45
+ /// be true. These encode relationships like `T: 'a` that are
46
+ /// added via implicit bounds.
47
+ ///
48
+ /// Each region here is guaranteed to be a key in the `indices`
49
+ /// map. We use the "original" regions (i.e., the keys from the
50
+ /// map, and not the values) because the code in
51
+ /// `process_registered_region_obligations` has some special-cased
52
+ /// logic expecting to see (e.g.) `ReStatic`, and if we supplied
53
+ /// our special inference variable there, we would mess that up.
54
+ type RegionBoundPairs < ' tcx > = Vec < ( ty:: Region < ' tcx > , GenericKind < ' tcx > ) > ;
55
+
56
56
crate fn create (
57
57
infcx : & InferCtxt < ' _ , ' _ , ' tcx > ,
58
58
mir_def_id : DefId ,
@@ -62,7 +62,7 @@ crate fn create(
62
62
universal_regions : & Rc < UniversalRegions < ' tcx > > ,
63
63
constraints : & mut MirTypeckRegionConstraints < ' tcx > ,
64
64
all_facts : & mut Option < AllFacts > ,
65
- ) -> Rc < UniversalRegionRelations < ' tcx > > {
65
+ ) -> ( Rc < UniversalRegionRelations < ' tcx > > , RegionBoundPairs < ' tcx > ) {
66
66
let mir_node_id = infcx. tcx . hir . as_local_node_id ( mir_def_id) . unwrap ( ) ;
67
67
UniversalRegionRelationsBuilder {
68
68
infcx,
@@ -74,9 +74,9 @@ crate fn create(
74
74
location_table,
75
75
all_facts,
76
76
universal_regions : universal_regions. clone ( ) ,
77
+ region_bound_pairs : Vec :: new ( ) ,
77
78
relations : UniversalRegionRelations {
78
79
universal_regions : universal_regions. clone ( ) ,
79
- region_bound_pairs : Vec :: new ( ) ,
80
80
outlives : TransitiveRelation :: new ( ) ,
81
81
inverse_outlives : TransitiveRelation :: new ( ) ,
82
82
} ,
@@ -205,14 +205,17 @@ struct UniversalRegionRelationsBuilder<'this, 'gcx: 'tcx, 'tcx: 'this> {
205
205
param_env : ty:: ParamEnv < ' tcx > ,
206
206
location_table : & ' this LocationTable ,
207
207
universal_regions : Rc < UniversalRegions < ' tcx > > ,
208
- relations : UniversalRegionRelations < ' tcx > ,
209
208
implicit_region_bound : Option < ty:: Region < ' tcx > > ,
210
209
constraints : & ' this mut MirTypeckRegionConstraints < ' tcx > ,
211
210
all_facts : & ' this mut Option < AllFacts > ,
211
+
212
+ // outputs:
213
+ relations : UniversalRegionRelations < ' tcx > ,
214
+ region_bound_pairs : RegionBoundPairs < ' tcx > ,
212
215
}
213
216
214
217
impl UniversalRegionRelationsBuilder < ' cx , ' gcx , ' tcx > {
215
- crate fn create ( mut self ) -> Rc < UniversalRegionRelations < ' tcx > > {
218
+ crate fn create ( mut self ) -> ( Rc < UniversalRegionRelations < ' tcx > > , RegionBoundPairs < ' tcx > ) {
216
219
let unnormalized_input_output_tys = self
217
220
. universal_regions
218
221
. unnormalized_input_tys
@@ -225,7 +228,7 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
225
228
// constraints, which we buffer up because we are
226
229
// not ready to process them yet.
227
230
// - Then compute the implied bounds. This will adjust
228
- // the `relations. region_bound_pairs` and so forth.
231
+ // the `region_bound_pairs` and so forth.
229
232
// - After this is done, we'll process the constraints, once
230
233
// the `relations` is built.
231
234
let constraint_sets: Vec < _ > = unnormalized_input_output_tys
@@ -267,7 +270,7 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
267
270
self . infcx . tcx ,
268
271
& self . universal_regions ,
269
272
& self . location_table ,
270
- & self . relations . region_bound_pairs ,
273
+ & self . region_bound_pairs ,
271
274
self . implicit_region_bound ,
272
275
self . param_env ,
273
276
Locations :: All ,
@@ -277,7 +280,7 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
277
280
) . convert_all ( & data) ;
278
281
}
279
282
280
- Rc :: new ( self . relations )
283
+ ( Rc :: new ( self . relations ) , self . region_bound_pairs )
281
284
}
282
285
283
286
/// Update the type of a single local, which should represent
@@ -312,14 +315,12 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
312
315
}
313
316
314
317
OutlivesBound :: RegionSubParam ( r_a, param_b) => {
315
- self . relations
316
- . region_bound_pairs
318
+ self . region_bound_pairs
317
319
. push ( ( r_a, GenericKind :: Param ( param_b) ) ) ;
318
320
}
319
321
320
322
OutlivesBound :: RegionSubProjection ( r_a, projection_b) => {
321
- self . relations
322
- . region_bound_pairs
323
+ self . region_bound_pairs
323
324
. push ( ( r_a, GenericKind :: Projection ( projection_b) ) ) ;
324
325
}
325
326
}
0 commit comments