Skip to content

Commit 490928f

Browse files
nikomatsakispnkfelix
authored andcommitted
remove region_bound_pairs from FRR as they are not needed later
1 parent 1e1f18d commit 490928f

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,6 @@ use syntax::ast;
2929
crate struct UniversalRegionRelations<'tcx> {
3030
universal_regions: Rc<UniversalRegions<'tcx>>,
3131

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-
4432
/// Stores the outlives relations that are known to hold from the
4533
/// implied bounds, in-scope where clauses, and that sort of
4634
/// thing.
@@ -53,6 +41,18 @@ crate struct UniversalRegionRelations<'tcx> {
5341
inverse_outlives: TransitiveRelation<RegionVid>,
5442
}
5543

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+
5656
crate fn create(
5757
infcx: &InferCtxt<'_, '_, 'tcx>,
5858
mir_def_id: DefId,
@@ -62,7 +62,7 @@ crate fn create(
6262
universal_regions: &Rc<UniversalRegions<'tcx>>,
6363
constraints: &mut MirTypeckRegionConstraints<'tcx>,
6464
all_facts: &mut Option<AllFacts>,
65-
) -> Rc<UniversalRegionRelations<'tcx>> {
65+
) -> (Rc<UniversalRegionRelations<'tcx>>, RegionBoundPairs<'tcx>) {
6666
let mir_node_id = infcx.tcx.hir.as_local_node_id(mir_def_id).unwrap();
6767
UniversalRegionRelationsBuilder {
6868
infcx,
@@ -74,9 +74,9 @@ crate fn create(
7474
location_table,
7575
all_facts,
7676
universal_regions: universal_regions.clone(),
77+
region_bound_pairs: Vec::new(),
7778
relations: UniversalRegionRelations {
7879
universal_regions: universal_regions.clone(),
79-
region_bound_pairs: Vec::new(),
8080
outlives: TransitiveRelation::new(),
8181
inverse_outlives: TransitiveRelation::new(),
8282
},
@@ -205,14 +205,17 @@ struct UniversalRegionRelationsBuilder<'this, 'gcx: 'tcx, 'tcx: 'this> {
205205
param_env: ty::ParamEnv<'tcx>,
206206
location_table: &'this LocationTable,
207207
universal_regions: Rc<UniversalRegions<'tcx>>,
208-
relations: UniversalRegionRelations<'tcx>,
209208
implicit_region_bound: Option<ty::Region<'tcx>>,
210209
constraints: &'this mut MirTypeckRegionConstraints<'tcx>,
211210
all_facts: &'this mut Option<AllFacts>,
211+
212+
// outputs:
213+
relations: UniversalRegionRelations<'tcx>,
214+
region_bound_pairs: RegionBoundPairs<'tcx>,
212215
}
213216

214217
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>) {
216219
let unnormalized_input_output_tys = self
217220
.universal_regions
218221
.unnormalized_input_tys
@@ -225,7 +228,7 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
225228
// constraints, which we buffer up because we are
226229
// not ready to process them yet.
227230
// - 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.
229232
// - After this is done, we'll process the constraints, once
230233
// the `relations` is built.
231234
let constraint_sets: Vec<_> = unnormalized_input_output_tys
@@ -267,7 +270,7 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
267270
self.infcx.tcx,
268271
&self.universal_regions,
269272
&self.location_table,
270-
&self.relations.region_bound_pairs,
273+
&self.region_bound_pairs,
271274
self.implicit_region_bound,
272275
self.param_env,
273276
Locations::All,
@@ -277,7 +280,7 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
277280
).convert_all(&data);
278281
}
279282

280-
Rc::new(self.relations)
283+
(Rc::new(self.relations), self.region_bound_pairs)
281284
}
282285

283286
/// Update the type of a single local, which should represent
@@ -312,14 +315,12 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
312315
}
313316

314317
OutlivesBound::RegionSubParam(r_a, param_b) => {
315-
self.relations
316-
.region_bound_pairs
318+
self.region_bound_pairs
317319
.push((r_a, GenericKind::Param(param_b)));
318320
}
319321

320322
OutlivesBound::RegionSubProjection(r_a, projection_b) => {
321-
self.relations
322-
.region_bound_pairs
323+
self.region_bound_pairs
323324
.push((r_a, GenericKind::Projection(projection_b)));
324325
}
325326
}

src/librustc_mir/borrow_check/nll/type_check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ pub(crate) fn type_check<'gcx, 'tcx>(
132132
type_tests: Vec::default(),
133133
};
134134

135-
let universal_region_relations = free_region_relations::create(
135+
let (universal_region_relations, region_bound_pairs) = free_region_relations::create(
136136
infcx,
137137
mir_def_id,
138138
param_env,
@@ -157,7 +157,7 @@ pub(crate) fn type_check<'gcx, 'tcx>(
157157
mir_def_id,
158158
param_env,
159159
mir,
160-
&universal_region_relations.region_bound_pairs,
160+
&region_bound_pairs,
161161
Some(implicit_region_bound),
162162
Some(&mut borrowck_context),
163163
Some(errors_buffer),

0 commit comments

Comments
 (0)