about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2018-04-07 07:11:01 -0400
committerNiko Matsakis <niko@alum.mit.edu>2018-04-15 07:06:30 -0400
commitd4005a2bc9adeb5a19b04bd4354e22e9e75a7072 (patch)
tree3c47f410608f58143dbec869bdea668a6a2c9fc1
parenta849da626d8e47265e6a70e1ff24997b935626bd (diff)
downloadrust-d4005a2bc9adeb5a19b04bd4354e22e9e75a7072.tar.gz
rust-d4005a2bc9adeb5a19b04bd4354e22e9e75a7072.zip
thread borrow-set around more
-rw-r--r--src/librustc_mir/borrow_check/mod.rs11
-rw-r--r--src/librustc_mir/borrow_check/nll/mod.rs2
-rw-r--r--src/librustc_mir/dataflow/impls/borrows.rs6
3 files changed, 11 insertions, 8 deletions
diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs
index 962356c6401..04f4aaf1332 100644
--- a/src/librustc_mir/borrow_check/mod.rs
+++ b/src/librustc_mir/borrow_check/mod.rs
@@ -193,7 +193,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
         |bd, i| DebugFormatted::new(&bd.move_data().inits[i]),
     ));
 
-    let borrow_set = BorrowSet::build(tcx, mir);
+    let borrow_set = Rc::new(BorrowSet::build(tcx, mir));
 
     // If we are in non-lexical mode, compute the non-lexical lifetimes.
     let (opt_regioncx, opt_closure_req) = if let Some(free_regions) = free_regions {
@@ -205,6 +205,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
             param_env,
             &mut flow_inits,
             &mdpe.move_data,
+            &borrow_set,
         );
         (Some(Rc::new(regioncx)), opt_closure_req)
     } else {
@@ -219,16 +220,16 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
         id,
         &attributes,
         &dead_unwinds,
-        Borrows::new(tcx, mir, opt_regioncx.clone(), def_id, body_id, borrow_set),
+        Borrows::new(tcx, mir, opt_regioncx.clone(), def_id, body_id, &borrow_set),
         |rs, i| DebugFormatted::new(&rs.location(i)),
     ));
 
-    let movable_generator = !match tcx.hir.get(id) {
+    let movable_generator = match tcx.hir.get(id) {
         hir::map::Node::NodeExpr(&hir::Expr {
             node: hir::ExprClosure(.., Some(hir::GeneratorMovability::Static)),
             ..
-        }) => true,
-        _ => false,
+        }) => false,
+        _ => true,
     };
 
     let dominators = mir.dominators();
diff --git a/src/librustc_mir/borrow_check/nll/mod.rs b/src/librustc_mir/borrow_check/nll/mod.rs
index 942e4fb56ca..3ca1bd23e86 100644
--- a/src/librustc_mir/borrow_check/nll/mod.rs
+++ b/src/librustc_mir/borrow_check/nll/mod.rs
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use borrow_check::borrow_set::BorrowSet;
 use rustc::hir::def_id::DefId;
 use rustc::mir::{ClosureRegionRequirements, ClosureOutlivesSubject, Mir};
 use rustc::infer::InferCtxt;
@@ -73,6 +74,7 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
     param_env: ty::ParamEnv<'gcx>,
     flow_inits: &mut FlowAtLocation<MaybeInitializedPlaces<'cx, 'gcx, 'tcx>>,
     move_data: &MoveData<'tcx>,
+    _borrow_set: &BorrowSet<'tcx>,
 ) -> (
     RegionInferenceContext<'tcx>,
     Option<ClosureRegionRequirements<'gcx>>,
diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs
index 19f5ad5589e..b1fa7eeb3a5 100644
--- a/src/librustc_mir/dataflow/impls/borrows.rs
+++ b/src/librustc_mir/dataflow/impls/borrows.rs
@@ -47,7 +47,7 @@ pub struct Borrows<'a, 'gcx: 'tcx, 'tcx: 'a> {
     scope_tree: Lrc<region::ScopeTree>,
     root_scope: Option<region::Scope>,
 
-    borrow_set: BorrowSet<'tcx>,
+    borrow_set: Rc<BorrowSet<'tcx>>,
 
     /// NLL region inference context with which NLL queries should be resolved
     nonlexical_regioncx: Option<Rc<RegionInferenceContext<'tcx>>>,
@@ -60,7 +60,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
         nonlexical_regioncx: Option<Rc<RegionInferenceContext<'tcx>>>,
         def_id: DefId,
         body_id: Option<hir::BodyId>,
-        borrow_set: BorrowSet<'tcx>
+        borrow_set: &Rc<BorrowSet<'tcx>>
     ) -> Self {
         let scope_tree = tcx.region_scope_tree(def_id);
         let root_scope = body_id.map(|body_id| {
@@ -70,7 +70,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
         Borrows {
             tcx: tcx,
             mir: mir,
-            borrow_set,
+            borrow_set: borrow_set.clone(),
             scope_tree,
             root_scope,
             nonlexical_regioncx,