Skip to content

Commit 5f7b74f

Browse files
committed
construct the BorrowSet outside of borrows
1 parent e112367 commit 5f7b74f

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/librustc_mir/borrow_check/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use util::collect_writes::FindAssignments;
4646

4747
use std::iter;
4848

49-
use self::borrow_set::BorrowData;
49+
use self::borrow_set::{BorrowSet, BorrowData};
5050
use self::flows::Flows;
5151
use self::prefixes::PrefixSet;
5252
use self::MutateMode::{JustWrite, WriteAndRead};
@@ -192,6 +192,8 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
192192
|bd, i| DebugFormatted::new(&bd.move_data().inits[i]),
193193
));
194194

195+
let borrow_set = BorrowSet::build(tcx, mir);
196+
195197
// If we are in non-lexical mode, compute the non-lexical lifetimes.
196198
let (opt_regioncx, opt_closure_req) = if let Some(free_regions) = free_regions {
197199
let (regioncx, opt_closure_req) = nll::compute_regions(
@@ -216,7 +218,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
216218
id,
217219
&attributes,
218220
&dead_unwinds,
219-
Borrows::new(tcx, mir, opt_regioncx.clone(), def_id, body_id),
221+
Borrows::new(tcx, mir, opt_regioncx.clone(), def_id, body_id, borrow_set),
220222
|rs, i| {
221223
DebugFormatted::new(&(i.kind(), rs.location(i.borrow_index())))
222224
}

src/librustc_mir/dataflow/impls/borrows.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,18 @@ impl ReserveOrActivateIndex {
6969
}
7070

7171
impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
72-
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
73-
mir: &'a Mir<'tcx>,
74-
nonlexical_regioncx: Option<Rc<RegionInferenceContext<'tcx>>>,
75-
def_id: DefId,
76-
body_id: Option<hir::BodyId>)
77-
-> Self {
72+
crate fn new(
73+
tcx: TyCtxt<'a, 'gcx, 'tcx>,
74+
mir: &'a Mir<'tcx>,
75+
nonlexical_regioncx: Option<Rc<RegionInferenceContext<'tcx>>>,
76+
def_id: DefId,
77+
body_id: Option<hir::BodyId>,
78+
borrow_set: BorrowSet<'tcx>
79+
) -> Self {
7880
let scope_tree = tcx.region_scope_tree(def_id);
7981
let root_scope = body_id.map(|body_id| {
8082
region::Scope::CallSite(tcx.hir.body(body_id).value.hir_id.local_id)
8183
});
82-
let borrow_set = BorrowSet::build(tcx, mir);
8384

8485
Borrows {
8586
tcx: tcx,

src/librustc_mir/dataflow/impls/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ mod borrowed_locals;
3838

3939
pub use self::borrowed_locals::*;
4040

41-
#[allow(dead_code)]
4241
pub(super) mod borrows;
4342

4443
/// `MaybeInitializedPlaces` tracks all places that might be

0 commit comments

Comments
 (0)