Skip to content

Commit 37ed41a

Browse files
Auto merge of #146697 - cjgillot:invalidate-patch, r=<try>
Avoid invalidating CFG caches from MirPatch::apply.
2 parents 2f4dfc7 + b216cf3 commit 37ed41a

File tree

1 file changed

+3
-3
lines changed
  • compiler/rustc_mir_transform/src

1 file changed

+3
-3
lines changed

compiler/rustc_mir_transform/src/patch.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl<'tcx> MirPatch<'tcx> {
244244
self.new_blocks.len(),
245245
body.basic_blocks.len()
246246
);
247-
let bbs = if self.term_patch_map.is_empty() && self.new_blocks.is_empty() {
247+
let bbs = if self.term_patch_map.iter().all(Option::is_none) && self.new_blocks.is_empty() {
248248
body.basic_blocks.as_mut_preserves_cfg()
249249
} else {
250250
body.basic_blocks.as_mut()
@@ -273,8 +273,8 @@ impl<'tcx> MirPatch<'tcx> {
273273
}
274274
debug!("MirPatch: adding statement {:?} at loc {:?}+{}", stmt, loc, delta);
275275
loc.statement_index += delta;
276-
let source_info = Self::source_info_for_index(&body[loc.block], loc);
277-
body[loc.block]
276+
let source_info = Self::source_info_for_index(&bbs[loc.block], loc);
277+
bbs[loc.block]
278278
.statements
279279
.insert(loc.statement_index, Statement::new(source_info, stmt));
280280
delta += 1;

0 commit comments

Comments
 (0)