Make MIR basic blocks field public
This makes it possible to mutably borrow different fields of the MIR body without resorting to methods like `basic_blocks_local_decls_mut_and_var_debug_info`. To preserve validity of control flow graph caches in the presence of modifications, a new struct `BasicBlocks` wraps together basic blocks and control flow graph caches. The `BasicBlocks` dereferences to `IndexVec<BasicBlock, BasicBlockData>`. On the other hand a mutable access requires explicit `as_mut()` call.
This commit is contained in:
parent
fac8fa5672
commit
c9dd1d9983
21 changed files with 213 additions and 195 deletions
|
@ -856,7 +856,8 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
|
|||
literal: ConstantKind::from_const(_const, tcx),
|
||||
}))
|
||||
};
|
||||
let (blocks, local_decls) = self.source.basic_blocks_and_local_decls_mut();
|
||||
let blocks = self.source.basic_blocks.as_mut();
|
||||
let local_decls = &mut self.source.local_decls;
|
||||
let loc = candidate.location;
|
||||
let statement = &mut blocks[loc.block].statements[loc.statement_index];
|
||||
match statement.kind {
|
||||
|
@ -865,7 +866,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
|
|||
Rvalue::Ref(ref mut region, borrow_kind, ref mut place),
|
||||
)) => {
|
||||
// Use the underlying local for this (necessarily interior) borrow.
|
||||
let ty = local_decls.local_decls()[place.local].ty;
|
||||
let ty = local_decls[place.local].ty;
|
||||
let span = statement.source_info.span;
|
||||
|
||||
let ref_ty = tcx.mk_ref(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue