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>, move_data: &MoveData<'tcx>, + _borrow_set: &BorrowSet<'tcx>, ) -> ( RegionInferenceContext<'tcx>, Option>, 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, root_scope: Option, - borrow_set: BorrowSet<'tcx>, + borrow_set: Rc>, /// NLL region inference context with which NLL queries should be resolved nonlexical_regioncx: Option>>, @@ -60,7 +60,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> { nonlexical_regioncx: Option>>, def_id: DefId, body_id: Option, - borrow_set: BorrowSet<'tcx> + borrow_set: &Rc> ) -> 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,