]> git.proxmox.com Git - rustc.git/blobdiff - src/librustc_mir/borrow_check/nll/constraint_generation.rs
New upstream version 1.40.0+dfsg1
[rustc.git] / src / librustc_mir / borrow_check / nll / constraint_generation.rs
index 1e5f613aedc233b20a0c3a84c91f6b6e377cf767..cae303039a19430e5f371da8de73e362d4ced40e 100644 (file)
@@ -8,11 +8,11 @@ use rustc::infer::InferCtxt;
 use rustc::mir::visit::TyContext;
 use rustc::mir::visit::Visitor;
 use rustc::mir::{
-    BasicBlock, BasicBlockData, Body, Local, Location, Place, PlaceBase, ProjectionElem, Rvalue,
-    SourceInfo, Statement, StatementKind, Terminator, TerminatorKind, UserTypeProjection,
+    BasicBlock, BasicBlockData, Body, Local, Location, Place, PlaceBase, PlaceRef, ProjectionElem,
+    Rvalue, SourceInfo, Statement, StatementKind, Terminator, TerminatorKind, UserTypeProjection,
 };
 use rustc::ty::fold::TypeFoldable;
-use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, RegionVid, Ty};
+use rustc::ty::{self, RegionVid, Ty};
 use rustc::ty::subst::SubstsRef;
 
 pub(super) fn generate_constraints<'cx, 'tcx>(
@@ -91,20 +91,6 @@ impl<'cg, 'cx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'tcx> {
         self.super_ty(ty);
     }
 
-    /// We sometimes have `generator_substs` within an rvalue, or within a
-    /// call. Make them live at the location where they appear.
-    fn visit_generator_substs(&mut self, substs: &GeneratorSubsts<'tcx>, location: Location) {
-        self.add_regular_live_constraint(*substs, location);
-        self.super_generator_substs(substs);
-    }
-
-    /// We sometimes have `closure_substs` within an rvalue, or within a
-    /// call. Make them live at the location where they appear.
-    fn visit_closure_substs(&mut self, substs: &ClosureSubsts<'tcx>, location: Location) {
-        self.add_regular_live_constraint(*substs, location);
-        self.super_closure_substs(substs);
-    }
-
     fn visit_statement(
         &mut self,
         statement: &Statement<'tcx>,
@@ -225,14 +211,14 @@ impl<'cx, 'cg, 'tcx> ConstraintGeneration<'cx, 'cg, 'tcx> {
             // - if it's a deeper projection, we have to filter which
             //   of the borrows are killed: the ones whose `borrowed_place`
             //   conflicts with the `place`.
-            match place {
-                Place {
-                    base: PlaceBase::Local(local),
-                    projection: box [],
+            match place.as_ref() {
+                PlaceRef {
+                    base: &PlaceBase::Local(local),
+                    projection: &[],
                 } |
-                Place {
-                    base: PlaceBase::Local(local),
-                    projection: box [ProjectionElem::Deref],
+                PlaceRef {
+                    base: &PlaceBase::Local(local),
+                    projection: &[ProjectionElem::Deref],
                 } => {
                     debug!(
                         "Recording `killed` facts for borrows of local={:?} at location={:?}",
@@ -243,21 +229,21 @@ impl<'cx, 'cg, 'tcx> ConstraintGeneration<'cx, 'cg, 'tcx> {
                         all_facts,
                         self.borrow_set,
                         self.location_table,
-                        local,
+                        &local,
                         location,
                     );
                 }
 
-                Place {
-                    base: PlaceBase::Static(_),
+                PlaceRef {
+                    base: &PlaceBase::Static(_),
                     ..
                 } => {
                     // Ignore kills of static or static mut variables.
                 }
 
-                Place {
-                    base: PlaceBase::Local(local),
-                    projection: box [.., _],
+                PlaceRef {
+                    base: &PlaceBase::Local(local),
+                    projection: &[.., _],
                 } => {
                     // Kill conflicting borrows of the innermost local.
                     debug!(
@@ -266,7 +252,7 @@ impl<'cx, 'cg, 'tcx> ConstraintGeneration<'cx, 'cg, 'tcx> {
                         local, location
                     );
 
-                    if let Some(borrow_indices) = self.borrow_set.local_map.get(local) {
+                    if let Some(borrow_indices) = self.borrow_set.local_map.get(&local) {
                         for &borrow_index in borrow_indices {
                             let places_conflict = places_conflict::places_conflict(
                                 self.infcx.tcx,