Skip to content

Commit d4005a2

Browse files
committed
thread borrow-set around more
1 parent a849da6 commit d4005a2

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/librustc_mir/borrow_check/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
193193
|bd, i| DebugFormatted::new(&bd.move_data().inits[i]),
194194
));
195195

196-
let borrow_set = BorrowSet::build(tcx, mir);
196+
let borrow_set = Rc::new(BorrowSet::build(tcx, mir));
197197

198198
// If we are in non-lexical mode, compute the non-lexical lifetimes.
199199
let (opt_regioncx, opt_closure_req) = if let Some(free_regions) = free_regions {
@@ -205,6 +205,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
205205
param_env,
206206
&mut flow_inits,
207207
&mdpe.move_data,
208+
&borrow_set,
208209
);
209210
(Some(Rc::new(regioncx)), opt_closure_req)
210211
} else {
@@ -219,16 +220,16 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
219220
id,
220221
&attributes,
221222
&dead_unwinds,
222-
Borrows::new(tcx, mir, opt_regioncx.clone(), def_id, body_id, borrow_set),
223+
Borrows::new(tcx, mir, opt_regioncx.clone(), def_id, body_id, &borrow_set),
223224
|rs, i| DebugFormatted::new(&rs.location(i)),
224225
));
225226

226-
let movable_generator = !match tcx.hir.get(id) {
227+
let movable_generator = match tcx.hir.get(id) {
227228
hir::map::Node::NodeExpr(&hir::Expr {
228229
node: hir::ExprClosure(.., Some(hir::GeneratorMovability::Static)),
229230
..
230-
}) => true,
231-
_ => false,
231+
}) => false,
232+
_ => true,
232233
};
233234

234235
let dominators = mir.dominators();

src/librustc_mir/borrow_check/nll/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use borrow_check::borrow_set::BorrowSet;
1112
use rustc::hir::def_id::DefId;
1213
use rustc::mir::{ClosureRegionRequirements, ClosureOutlivesSubject, Mir};
1314
use rustc::infer::InferCtxt;
@@ -73,6 +74,7 @@ pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
7374
param_env: ty::ParamEnv<'gcx>,
7475
flow_inits: &mut FlowAtLocation<MaybeInitializedPlaces<'cx, 'gcx, 'tcx>>,
7576
move_data: &MoveData<'tcx>,
77+
_borrow_set: &BorrowSet<'tcx>,
7678
) -> (
7779
RegionInferenceContext<'tcx>,
7880
Option<ClosureRegionRequirements<'gcx>>,

src/librustc_mir/dataflow/impls/borrows.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub struct Borrows<'a, 'gcx: 'tcx, 'tcx: 'a> {
4747
scope_tree: Lrc<region::ScopeTree>,
4848
root_scope: Option<region::Scope>,
4949

50-
borrow_set: BorrowSet<'tcx>,
50+
borrow_set: Rc<BorrowSet<'tcx>>,
5151

5252
/// NLL region inference context with which NLL queries should be resolved
5353
nonlexical_regioncx: Option<Rc<RegionInferenceContext<'tcx>>>,
@@ -60,7 +60,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
6060
nonlexical_regioncx: Option<Rc<RegionInferenceContext<'tcx>>>,
6161
def_id: DefId,
6262
body_id: Option<hir::BodyId>,
63-
borrow_set: BorrowSet<'tcx>
63+
borrow_set: &Rc<BorrowSet<'tcx>>
6464
) -> Self {
6565
let scope_tree = tcx.region_scope_tree(def_id);
6666
let root_scope = body_id.map(|body_id| {
@@ -70,7 +70,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
7070
Borrows {
7171
tcx: tcx,
7272
mir: mir,
73-
borrow_set,
73+
borrow_set: borrow_set.clone(),
7474
scope_tree,
7575
root_scope,
7676
nonlexical_regioncx,

0 commit comments

Comments
 (0)