Replace Body::basic_blocks()
with field access
This commit is contained in:
parent
983f4daddf
commit
b48870b451
65 changed files with 131 additions and 140 deletions
|
@ -19,7 +19,7 @@ pub struct MirPatch<'tcx> {
|
|||
impl<'tcx> MirPatch<'tcx> {
|
||||
pub fn new(body: &Body<'tcx>) -> Self {
|
||||
let mut result = MirPatch {
|
||||
patch_map: IndexVec::from_elem(None, body.basic_blocks()),
|
||||
patch_map: IndexVec::from_elem(None, &body.basic_blocks),
|
||||
new_blocks: vec![],
|
||||
new_statements: vec![],
|
||||
new_locals: vec![],
|
||||
|
@ -29,7 +29,7 @@ impl<'tcx> MirPatch<'tcx> {
|
|||
};
|
||||
|
||||
// Check if we already have a resume block
|
||||
for (bb, block) in body.basic_blocks().iter_enumerated() {
|
||||
for (bb, block) in body.basic_blocks.iter_enumerated() {
|
||||
if let TerminatorKind::Resume = block.terminator().kind && block.statements.is_empty() {
|
||||
result.resume_block = Some(bb);
|
||||
break;
|
||||
|
@ -61,7 +61,7 @@ impl<'tcx> MirPatch<'tcx> {
|
|||
}
|
||||
|
||||
pub fn terminator_loc(&self, body: &Body<'tcx>, bb: BasicBlock) -> Location {
|
||||
let offset = match bb.index().checked_sub(body.basic_blocks().len()) {
|
||||
let offset = match bb.index().checked_sub(body.basic_blocks.len()) {
|
||||
Some(index) => self.new_blocks[index].statements.len(),
|
||||
None => body[bb].statements.len(),
|
||||
};
|
||||
|
@ -129,7 +129,7 @@ impl<'tcx> MirPatch<'tcx> {
|
|||
debug!(
|
||||
"MirPatch: {} new blocks, starting from index {}",
|
||||
self.new_blocks.len(),
|
||||
body.basic_blocks().len()
|
||||
body.basic_blocks.len()
|
||||
);
|
||||
let bbs = if self.patch_map.is_empty() && self.new_blocks.is_empty() {
|
||||
body.basic_blocks.as_mut_preserves_cfg()
|
||||
|
@ -173,7 +173,7 @@ impl<'tcx> MirPatch<'tcx> {
|
|||
}
|
||||
|
||||
pub fn source_info_for_location(&self, body: &Body<'tcx>, loc: Location) -> SourceInfo {
|
||||
let data = match loc.block.index().checked_sub(body.basic_blocks().len()) {
|
||||
let data = match loc.block.index().checked_sub(body.basic_blocks.len()) {
|
||||
Some(new) => &self.new_blocks[new],
|
||||
None => &body[loc.block],
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue