about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2018-07-26 14:49:45 +0300
committerFelix S. Klock II <pnkfelix@pnkfx.org>2018-07-31 02:31:41 +0200
commit1e1f18ddba20b370d6cdd85d60e7e415a94094b5 (patch)
treea17f61ffc51640e7d5f46a5af73fdf1ec6633e41
parentd42bc58b1dc881883444142e7898206a12bf5064 (diff)
downloadrust-1e1f18ddba20b370d6cdd85d60e7e415a94094b5.tar.gz
rust-1e1f18ddba20b370d6cdd85d60e7e415a94094b5.zip
make a free fn for creating the URR
-rw-r--r--src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs64
-rw-r--r--src/librustc_mir/borrow_check/nll/type_check/mod.rs21
2 files changed, 42 insertions, 43 deletions
diff --git a/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs b/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs
index d2850f8f324..a539bf5f3aa 100644
--- a/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs
+++ b/src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs
@@ -9,11 +9,11 @@
 // except according to those terms.
 
 use borrow_check::location::LocationTable;
-use borrow_check::nll::ToRegionVid;
 use borrow_check::nll::facts::AllFacts;
 use borrow_check::nll::type_check::constraint_conversion;
 use borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints};
 use borrow_check::nll::universal_regions::UniversalRegions;
+use borrow_check::nll::ToRegionVid;
 use rustc::hir::def_id::DefId;
 use rustc::infer::outlives::free_region_map::FreeRegionRelations;
 use rustc::infer::region_constraints::GenericKind;
@@ -53,37 +53,37 @@ crate struct UniversalRegionRelations<'tcx> {
     inverse_outlives: TransitiveRelation<RegionVid>,
 }
 
-impl UniversalRegionRelations<'tcx> {
-    crate fn create(
-        infcx: &InferCtxt<'_, '_, 'tcx>,
-        mir_def_id: DefId,
-        param_env: ty::ParamEnv<'tcx>,
-        location_table: &LocationTable,
-        implicit_region_bound: Option<ty::Region<'tcx>>,
-        universal_regions: &Rc<UniversalRegions<'tcx>>,
-        constraints: &mut MirTypeckRegionConstraints<'tcx>,
-        all_facts: &mut Option<AllFacts>,
-    ) -> Self {
-        let mir_node_id = infcx.tcx.hir.as_local_node_id(mir_def_id).unwrap();
-        UniversalRegionRelationsBuilder {
-            infcx,
-            mir_def_id,
-            mir_node_id,
-            param_env,
-            implicit_region_bound,
-            constraints,
-            location_table,
-            all_facts,
+crate fn create(
+    infcx: &InferCtxt<'_, '_, 'tcx>,
+    mir_def_id: DefId,
+    param_env: ty::ParamEnv<'tcx>,
+    location_table: &LocationTable,
+    implicit_region_bound: Option<ty::Region<'tcx>>,
+    universal_regions: &Rc<UniversalRegions<'tcx>>,
+    constraints: &mut MirTypeckRegionConstraints<'tcx>,
+    all_facts: &mut Option<AllFacts>,
+) -> Rc<UniversalRegionRelations<'tcx>> {
+    let mir_node_id = infcx.tcx.hir.as_local_node_id(mir_def_id).unwrap();
+    UniversalRegionRelationsBuilder {
+        infcx,
+        mir_def_id,
+        mir_node_id,
+        param_env,
+        implicit_region_bound,
+        constraints,
+        location_table,
+        all_facts,
+        universal_regions: universal_regions.clone(),
+        relations: UniversalRegionRelations {
             universal_regions: universal_regions.clone(),
-            relations: UniversalRegionRelations {
-                universal_regions: universal_regions.clone(),
-                region_bound_pairs: Vec::new(),
-                outlives: TransitiveRelation::new(),
-                inverse_outlives: TransitiveRelation::new(),
-            },
-        }.create()
-    }
+            region_bound_pairs: Vec::new(),
+            outlives: TransitiveRelation::new(),
+            inverse_outlives: TransitiveRelation::new(),
+        },
+    }.create()
+}
 
+impl UniversalRegionRelations<'tcx> {
     /// Records in the `outlives_relation` (and
     /// `inverse_outlives_relation`) that `fr_a: fr_b`. Invoked by the
     /// builder below.
@@ -212,7 +212,7 @@ struct UniversalRegionRelationsBuilder<'this, 'gcx: 'tcx, 'tcx: 'this> {
 }
 
 impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
-    crate fn create(mut self) -> UniversalRegionRelations<'tcx> {
+    crate fn create(mut self) -> Rc<UniversalRegionRelations<'tcx>> {
         let unnormalized_input_output_tys = self
             .universal_regions
             .unnormalized_input_tys
@@ -277,7 +277,7 @@ impl UniversalRegionRelationsBuilder<'cx, 'gcx, 'tcx> {
             ).convert_all(&data);
         }
 
-        self.relations
+        Rc::new(self.relations)
     }
 
     /// Update the type of a single local, which should represent
diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs
index 15deb5fb2f4..d4a4e17849c 100644
--- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs
+++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs
@@ -132,17 +132,16 @@ pub(crate) fn type_check<'gcx, 'tcx>(
         type_tests: Vec::default(),
     };
 
-    let universal_region_relations =
-        Rc::new(free_region_relations::UniversalRegionRelations::create(
-            infcx,
-            mir_def_id,
-            param_env,
-            location_table,
-            Some(implicit_region_bound),
-            universal_regions,
-            &mut constraints,
-            all_facts,
-        ));
+    let universal_region_relations = free_region_relations::create(
+        infcx,
+        mir_def_id,
+        param_env,
+        location_table,
+        Some(implicit_region_bound),
+        universal_regions,
+        &mut constraints,
+        all_facts,
+    );
 
     {
         let mut borrowck_context = BorrowCheckContext {