construct the BorrowSet
outside of borrows
This commit is contained in:
parent
e1123674b1
commit
5f7b74f832
3 changed files with 12 additions and 10 deletions
|
@ -46,7 +46,7 @@ use util::collect_writes::FindAssignments;
|
|||
|
||||
use std::iter;
|
||||
|
||||
use self::borrow_set::BorrowData;
|
||||
use self::borrow_set::{BorrowSet, BorrowData};
|
||||
use self::flows::Flows;
|
||||
use self::prefixes::PrefixSet;
|
||||
use self::MutateMode::{JustWrite, WriteAndRead};
|
||||
|
@ -192,6 +192,8 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
|
|||
|bd, i| DebugFormatted::new(&bd.move_data().inits[i]),
|
||||
));
|
||||
|
||||
let borrow_set = 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 {
|
||||
let (regioncx, opt_closure_req) = nll::compute_regions(
|
||||
|
@ -216,7 +218,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
|
|||
id,
|
||||
&attributes,
|
||||
&dead_unwinds,
|
||||
Borrows::new(tcx, mir, opt_regioncx.clone(), def_id, body_id),
|
||||
Borrows::new(tcx, mir, opt_regioncx.clone(), def_id, body_id, borrow_set),
|
||||
|rs, i| {
|
||||
DebugFormatted::new(&(i.kind(), rs.location(i.borrow_index())))
|
||||
}
|
||||
|
|
|
@ -69,17 +69,18 @@ impl ReserveOrActivateIndex {
|
|||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
|
||||
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
nonlexical_regioncx: Option<Rc<RegionInferenceContext<'tcx>>>,
|
||||
def_id: DefId,
|
||||
body_id: Option<hir::BodyId>)
|
||||
-> Self {
|
||||
crate fn new(
|
||||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
mir: &'a Mir<'tcx>,
|
||||
nonlexical_regioncx: Option<Rc<RegionInferenceContext<'tcx>>>,
|
||||
def_id: DefId,
|
||||
body_id: Option<hir::BodyId>,
|
||||
borrow_set: BorrowSet<'tcx>
|
||||
) -> Self {
|
||||
let scope_tree = tcx.region_scope_tree(def_id);
|
||||
let root_scope = body_id.map(|body_id| {
|
||||
region::Scope::CallSite(tcx.hir.body(body_id).value.hir_id.local_id)
|
||||
});
|
||||
let borrow_set = BorrowSet::build(tcx, mir);
|
||||
|
||||
Borrows {
|
||||
tcx: tcx,
|
||||
|
|
|
@ -38,7 +38,6 @@ mod borrowed_locals;
|
|||
|
||||
pub use self::borrowed_locals::*;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(super) mod borrows;
|
||||
|
||||
/// `MaybeInitializedPlaces` tracks all places that might be
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue