thread borrow-set around more

This commit is contained in:
Niko Matsakis 2018-04-07 07:11:01 -04:00
parent a849da626d
commit d4005a2bc9
3 changed files with 11 additions and 8 deletions

View File

@ -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();

View File

@ -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>>,

View File

@ -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,