Skip to content

Commit 1e1f18d

Browse files
nikomatsakispnkfelix
authored andcommitted
make a free fn for creating the URR
1 parent d42bc58 commit 1e1f18d

File tree

2 files changed

+42
-43
lines changed

2 files changed

+42
-43
lines changed

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

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// except according to those terms.
1010

1111
use borrow_check::location::LocationTable;
12-
use borrow_check::nll::ToRegionVid;
1312
use borrow_check::nll::facts::AllFacts;
1413
use borrow_check::nll::type_check::constraint_conversion;
1514
use borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints};
1615
use borrow_check::nll::universal_regions::UniversalRegions;
16+
use borrow_check::nll::ToRegionVid;
1717
use rustc::hir::def_id::DefId;
1818
use rustc::infer::outlives::free_region_map::FreeRegionRelations;
1919
use rustc::infer::region_constraints::GenericKind;
@@ -53,37 +53,37 @@ crate struct UniversalRegionRelations<'tcx> {
5353
inverse_outlives: TransitiveRelation<RegionVid>,
5454
}
5555

56-
impl UniversalRegionRelations<'tcx> {
57-
crate fn create(
58-
infcx: &InferCtxt<'_, '_, 'tcx>,
59-
mir_def_id: DefId,
60-
param_env: ty::ParamEnv<'tcx>,
61-
location_table: &LocationTable,
62-
implicit_region_bound: Option<ty::Region<'tcx>>,
63-
universal_regions: &Rc<UniversalRegions<'tcx>>,
64-
constraints: &mut MirTypeckRegionConstraints<'tcx>,
65-
all_facts: &mut Option<AllFacts>,
66-
) -> Self {
67-
let mir_node_id = infcx.tcx.hir.as_local_node_id(mir_def_id).unwrap();
68-
UniversalRegionRelationsBuilder {
69-
infcx,
70-
mir_def_id,
71-
mir_node_id,
72-
param_env,
73-
implicit_region_bound,
74-
constraints,
75-
location_table,
76-
all_facts,
56+
crate fn create(
57+
infcx: &InferCtxt<'_, '_, 'tcx>,
58+
mir_def_id: DefId,
59+
param_env: ty::ParamEnv<'tcx>,
60+
location_table: &LocationTable,
61+
implicit_region_bound: Option<ty::Region<'tcx>>,
62+
universal_regions: &Rc<UniversalRegions<'tcx>>,
63+
constraints: &mut MirTypeckRegionConstraints<'tcx>,
64+
all_facts: &mut Option<AllFacts>,
65+
) -> Rc<UniversalRegionRelations<'tcx>> {
66+
let mir_node_id = infcx.tcx.hir.as_local_node_id(mir_def_id).unwrap();
67+
UniversalRegionRelationsBuilder {
68+
infcx,
69+
mir_def_id,
70+
mir_node_id,
71+
param_env,
72+
implicit_region_bound,
73+
constraints,
74+
location_table,
75+
all_facts,
76+
universal_regions: universal_regions.clone(),
77+
relations: UniversalRegionRelations {
7778
universal_regions: universal_regions.clone(),
78-
relations: UniversalRegionRelations {
79-
universal_regions: universal_regions.clone(),
80-
region_bound_pairs: Vec::new(),
81-
outlives: TransitiveRelation::new(),
82-
inverse_outlives: TransitiveRelation::new(),
83-
},
84-
}.create()
85-
}
79+
region_bound_pairs: Vec::new(),
80+
outlives: TransitiveRelation::new(),
81+
inverse_outlives: TransitiveRelation::new(),
82+
},
83+
}.create()
84+
}
8685

86+
impl UniversalRegionRelations<'tcx> {
8787
/// Records in the `outlives_relation` (and
8888
/// `inverse_outlives_relation`) that `fr_a: fr_b`. Invoked by the
8989
/// builder below.
@@ -212,7 +212,7 @@ struct UniversalRegionRelationsBuilder<'this, 'gcx: 'tcx, 'tcx: 'this> {
212212
}
213213

214214
impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
215-
crate fn create(mut self) -> UniversalRegionRelations<'tcx> {
215+
crate fn create(mut self) -> Rc<UniversalRegionRelations<'tcx>> {
216216
let unnormalized_input_output_tys = self
217217
.universal_regions
218218
.unnormalized_input_tys
@@ -277,7 +277,7 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
277277
).convert_all(&data);
278278
}
279279

280-
self.relations
280+
Rc::new(self.relations)
281281
}
282282

283283
/// Update the type of a single local, which should represent

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

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

135-
let universal_region_relations =
136-
Rc::new(free_region_relations::UniversalRegionRelations::create(
137-
infcx,
138-
mir_def_id,
139-
param_env,
140-
location_table,
141-
Some(implicit_region_bound),
142-
universal_regions,
143-
&mut constraints,
144-
all_facts,
145-
));
135+
let universal_region_relations = free_region_relations::create(
136+
infcx,
137+
mir_def_id,
138+
param_env,
139+
location_table,
140+
Some(implicit_region_bound),
141+
universal_regions,
142+
&mut constraints,
143+
all_facts,
144+
);
146145

147146
{
148147
let mut borrowck_context = BorrowCheckContext {

0 commit comments

Comments
 (0)