Compute dominators on demand for borrowck.
This commit is contained in:
parent
ae318e3444
commit
7bd4fde684
2 changed files with 8 additions and 8 deletions
|
@ -2382,7 +2382,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
let mut back_edge_stack = Vec::new();
|
let mut back_edge_stack = Vec::new();
|
||||||
|
|
||||||
predecessor_locations(self.body, location).for_each(|predecessor| {
|
predecessor_locations(self.body, location).for_each(|predecessor| {
|
||||||
if location.dominates(predecessor, self.dominators) {
|
if location.dominates(predecessor, self.dominators()) {
|
||||||
back_edge_stack.push(predecessor)
|
back_edge_stack.push(predecessor)
|
||||||
} else {
|
} else {
|
||||||
stack.push(predecessor);
|
stack.push(predecessor);
|
||||||
|
@ -2494,7 +2494,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
|
|
||||||
let mut has_predecessor = false;
|
let mut has_predecessor = false;
|
||||||
predecessor_locations(self.body, location).for_each(|predecessor| {
|
predecessor_locations(self.body, location).for_each(|predecessor| {
|
||||||
if location.dominates(predecessor, self.dominators) {
|
if location.dominates(predecessor, self.dominators()) {
|
||||||
back_edge_stack.push(predecessor)
|
back_edge_stack.push(predecessor)
|
||||||
} else {
|
} else {
|
||||||
stack.push(predecessor);
|
stack.push(predecessor);
|
||||||
|
|
|
@ -330,7 +330,6 @@ fn do_mir_borrowck<'tcx>(
|
||||||
used_mut: Default::default(),
|
used_mut: Default::default(),
|
||||||
used_mut_upvars: SmallVec::new(),
|
used_mut_upvars: SmallVec::new(),
|
||||||
borrow_set: Rc::clone(&borrow_set),
|
borrow_set: Rc::clone(&borrow_set),
|
||||||
dominators: promoted_body.basic_blocks.dominators(),
|
|
||||||
upvars: Vec::new(),
|
upvars: Vec::new(),
|
||||||
local_names: IndexVec::from_elem(None, &promoted_body.local_decls),
|
local_names: IndexVec::from_elem(None, &promoted_body.local_decls),
|
||||||
region_names: RefCell::default(),
|
region_names: RefCell::default(),
|
||||||
|
@ -359,7 +358,6 @@ fn do_mir_borrowck<'tcx>(
|
||||||
used_mut: Default::default(),
|
used_mut: Default::default(),
|
||||||
used_mut_upvars: SmallVec::new(),
|
used_mut_upvars: SmallVec::new(),
|
||||||
borrow_set: Rc::clone(&borrow_set),
|
borrow_set: Rc::clone(&borrow_set),
|
||||||
dominators: body.basic_blocks.dominators(),
|
|
||||||
upvars,
|
upvars,
|
||||||
local_names,
|
local_names,
|
||||||
region_names: RefCell::default(),
|
region_names: RefCell::default(),
|
||||||
|
@ -590,9 +588,6 @@ struct MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
/// The set of borrows extracted from the MIR
|
/// The set of borrows extracted from the MIR
|
||||||
borrow_set: Rc<BorrowSet<'tcx>>,
|
borrow_set: Rc<BorrowSet<'tcx>>,
|
||||||
|
|
||||||
/// Dominators for MIR
|
|
||||||
dominators: &'cx Dominators<BasicBlock>,
|
|
||||||
|
|
||||||
/// Information about upvars not necessarily preserved in types or MIR
|
/// Information about upvars not necessarily preserved in types or MIR
|
||||||
upvars: Vec<Upvar<'tcx>>,
|
upvars: Vec<Upvar<'tcx>>,
|
||||||
|
|
||||||
|
@ -1102,7 +1097,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
|
|
||||||
(Read(kind), BorrowKind::Unique | BorrowKind::Mut { .. }) => {
|
(Read(kind), BorrowKind::Unique | BorrowKind::Mut { .. }) => {
|
||||||
// Reading from mere reservations of mutable-borrows is OK.
|
// Reading from mere reservations of mutable-borrows is OK.
|
||||||
if !is_active(this.dominators, borrow, location) {
|
if !is_active(this.dominators(), borrow, location) {
|
||||||
assert!(allow_two_phase_borrow(borrow.kind));
|
assert!(allow_two_phase_borrow(borrow.kind));
|
||||||
return Control::Continue;
|
return Control::Continue;
|
||||||
}
|
}
|
||||||
|
@ -2266,6 +2261,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||||
fn is_upvar_field_projection(&self, place_ref: PlaceRef<'tcx>) -> Option<FieldIdx> {
|
fn is_upvar_field_projection(&self, place_ref: PlaceRef<'tcx>) -> Option<FieldIdx> {
|
||||||
path_utils::is_upvar_field_projection(self.infcx.tcx, &self.upvars, place_ref, self.body())
|
path_utils::is_upvar_field_projection(self.infcx.tcx, &self.upvars, place_ref, self.body())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn dominators(&self) -> &Dominators<BasicBlock> {
|
||||||
|
// `BasicBlocks` computes dominators on-demand and caches them.
|
||||||
|
self.body.basic_blocks.dominators()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod error {
|
mod error {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue