Cache dominators.
This commit is contained in:
parent
aa1267f630
commit
6f271dc49c
6 changed files with 19 additions and 19 deletions
|
@ -43,7 +43,6 @@ use rustc_target::abi::FieldIdx;
|
|||
|
||||
use either::Either;
|
||||
use smallvec::SmallVec;
|
||||
use std::cell::OnceCell;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::BTreeMap;
|
||||
use std::ops::Deref;
|
||||
|
@ -331,7 +330,7 @@ fn do_mir_borrowck<'tcx>(
|
|||
used_mut: Default::default(),
|
||||
used_mut_upvars: SmallVec::new(),
|
||||
borrow_set: Rc::clone(&borrow_set),
|
||||
dominators: Default::default(),
|
||||
dominators: promoted_body.basic_blocks.dominators(),
|
||||
upvars: Vec::new(),
|
||||
local_names: IndexVec::from_elem(None, &promoted_body.local_decls),
|
||||
region_names: RefCell::default(),
|
||||
|
@ -360,7 +359,7 @@ fn do_mir_borrowck<'tcx>(
|
|||
used_mut: Default::default(),
|
||||
used_mut_upvars: SmallVec::new(),
|
||||
borrow_set: Rc::clone(&borrow_set),
|
||||
dominators: Default::default(),
|
||||
dominators: body.basic_blocks.dominators(),
|
||||
upvars,
|
||||
local_names,
|
||||
region_names: RefCell::default(),
|
||||
|
@ -592,7 +591,7 @@ struct MirBorrowckCtxt<'cx, 'tcx> {
|
|||
borrow_set: Rc<BorrowSet<'tcx>>,
|
||||
|
||||
/// Dominators for MIR
|
||||
dominators: OnceCell<Dominators<BasicBlock>>,
|
||||
dominators: &'cx Dominators<BasicBlock>,
|
||||
|
||||
/// Information about upvars not necessarily preserved in types or MIR
|
||||
upvars: Vec<Upvar<'tcx>>,
|
||||
|
@ -1103,7 +1102,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
|
||||
(Read(kind), BorrowKind::Unique | BorrowKind::Mut { .. }) => {
|
||||
// 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));
|
||||
return Control::Continue;
|
||||
}
|
||||
|
@ -2267,10 +2266,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
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())
|
||||
}
|
||||
|
||||
fn dominators(&self) -> &Dominators<BasicBlock> {
|
||||
self.dominators.get_or_init(|| self.body.basic_blocks.dominators())
|
||||
}
|
||||
}
|
||||
|
||||
mod error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue