]> git.lizzy.rs Git - rust.git/commitdiff
pass `UniversalRegions` to MIR type-checker instead of fields
authorNiko Matsakis <niko@alum.mit.edu>
Sun, 10 Dec 2017 14:55:43 +0000 (09:55 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 20 Dec 2017 19:04:52 +0000 (14:04 -0500)
No functional change.

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

index d18883ce47cbd70dc07ce11a39b74d6ead600804..7acbe2ebf932890827ba89f3e48c21eb95e65c3e 100644 (file)
@@ -79,16 +79,12 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
     // Run the MIR type-checker.
     let mir_node_id = infcx.tcx.hir.as_local_node_id(def_id).unwrap();
     let liveness = &LivenessResults::compute(mir);
-    let fr_fn_body = infcx.tcx.mk_region(ty::ReVar(universal_regions.fr_fn_body));
     let constraint_sets = &type_check::type_check(
         infcx,
         mir_node_id,
         param_env,
         mir,
-        &universal_regions.region_bound_pairs,
-        fr_fn_body,
-        universal_regions.input_tys,
-        universal_regions.output_ty,
+        &universal_regions,
         &liveness,
         flow_inits,
         move_data,
index ee455c3e921f1a44bbee891eb20c8cc3982989ff..a56fb0492761eb2986f407639fbccfd51e2380c9 100644 (file)
@@ -13,6 +13,7 @@
 
 use borrow_check::nll::region_infer::Cause;
 use borrow_check::nll::region_infer::ClosureRegionRequirementsExt;
+use borrow_check::nll::universal_regions::UniversalRegions;
 use dataflow::FlowAtLocation;
 use dataflow::MaybeInitializedLvals;
 use dataflow::move_paths::MoveData;
@@ -71,28 +72,32 @@ pub(crate) fn type_check<'gcx, 'tcx>(
     body_id: ast::NodeId,
     param_env: ty::ParamEnv<'gcx>,
     mir: &Mir<'tcx>,
-    region_bound_pairs: &[(ty::Region<'tcx>, GenericKind<'tcx>)],
-    implicit_region_bound: ty::Region<'tcx>,
-    input_tys: &[Ty<'tcx>],
-    output_ty: Ty<'tcx>,
+    universal_regions: &UniversalRegions<'tcx>,
     liveness: &LivenessResults,
     flow_inits: &mut FlowAtLocation<MaybeInitializedLvals<'_, 'gcx, 'tcx>>,
     move_data: &MoveData<'tcx>,
 ) -> MirTypeckRegionConstraints<'tcx> {
+    let implicit_region_bound = infcx.tcx.mk_region(ty::ReVar(universal_regions.fr_fn_body));
     type_check_internal(
         infcx,
         body_id,
         param_env,
         mir,
-        region_bound_pairs,
+        &universal_regions.region_bound_pairs,
         Some(implicit_region_bound),
         &mut |cx| {
             liveness::generate(cx, mir, liveness, flow_inits, move_data);
 
             // Equate the input and output tys given by the user with
             // the ones found in the MIR.
-            cx.equate_input_or_output(output_ty, mir.local_decls[RETURN_PLACE].ty);
-            for (&input_ty, local) in input_tys.iter().zip((1..).map(Local::new)) {
+            let &UniversalRegions {
+                unnormalized_output_ty,
+                unnormalized_input_tys,
+                ..
+            } = universal_regions;
+            cx.equate_input_or_output(unnormalized_output_ty, mir.local_decls[RETURN_PLACE].ty);
+            let arg_locals = (1..).map(Local::new);
+            for (&input_ty, local) in unnormalized_input_tys.iter().zip(arg_locals) {
                 cx.equate_input_or_output(input_ty, mir.local_decls[local].ty);
             }
         },
index 8f7616430241facd2b67e62d916f5162bd946cf8..070cea4bef2e3610563bd083ba1146fe81d73a05 100644 (file)
@@ -70,16 +70,18 @@ pub struct UniversalRegions<'tcx> {
     pub defining_ty: DefiningTy<'tcx>,
 
     /// The return type of this function, with all regions replaced by
-    /// their universal `RegionVid` equivalents. This type is **NOT
-    /// NORMALIZED** (i.e., it contains unnormalized associated type
-    /// projections).
-    pub output_ty: Ty<'tcx>,
+    /// their universal `RegionVid` equivalents.
+    ///
+    /// NB. Associated types in this type have not been normalized,
+    /// as the name suggests. =)
+    pub unnormalized_output_ty: Ty<'tcx>,
 
     /// The fully liberated input types of this function, with all
     /// regions replaced by their universal `RegionVid` equivalents.
-    /// This type is **NOT NORMALIZED** (i.e., it contains
-    /// unnormalized associated type projections).
-    pub input_tys: &'tcx [Ty<'tcx>],
+    ///
+    /// NB. Associated types in these types have not been normalized,
+    /// as the name suggests. =)
+    pub unnormalized_input_tys: &'tcx [Ty<'tcx>],
 
     /// Each RBP `('a, GK)` indicates that `GK: 'a` can be assumed to
     /// be true. These encode relationships like `T: 'a` that are
@@ -479,7 +481,8 @@ fn build(mut self) -> UniversalRegions<'tcx> {
             self.relations.relate_universal_regions(fr, fr_fn_body);
         }
 
-        let (output_ty, input_tys) = inputs_and_output.split_last().unwrap();
+        let (unnormalized_output_ty, unnormalized_input_tys) =
+            inputs_and_output.split_last().unwrap();
 
         // we should not have created any more variables
         assert_eq!(self.infcx.num_region_vars(), num_universals);
@@ -508,8 +511,8 @@ fn build(mut self) -> UniversalRegions<'tcx> {
             first_local_index,
             num_universals,
             defining_ty,
-            output_ty,
-            input_tys,
+            unnormalized_output_ty,
+            unnormalized_input_tys,
             region_bound_pairs: self.region_bound_pairs,
             relations: self.relations,
         }