Skip to content

Commit 4ed8cfc

Browse files
authored
Rollup merge of #107323 - JakobDegen:const-goto, r=tmiasko
Disable ConstGoto opt in cleanup blocks Fixes #107315 . There is probably a smaller hammer that we could use here, but none that is super obviously correct. We can always revisit this in the future. Could not add a test because custom mir does not support cleanup blocks. However, did check that the fallible_iterator crate no longer ICEs with the other PR cherry picked. r? `@tmiasko`
2 parents c87996a + f8aaf9a commit 4ed8cfc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

compiler/rustc_mir_transform/src/const_goto.rs

+9
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ impl<'tcx> MirPass<'tcx> for ConstGoto {
5757
}
5858

5959
impl<'tcx> Visitor<'tcx> for ConstGotoOptimizationFinder<'_, 'tcx> {
60+
fn visit_basic_block_data(&mut self, block: BasicBlock, data: &BasicBlockData<'tcx>) {
61+
if data.is_cleanup {
62+
// Because of the restrictions around control flow in cleanup blocks, we don't perform
63+
// this optimization at all in such blocks.
64+
return;
65+
}
66+
self.super_basic_block_data(block, data);
67+
}
68+
6069
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
6170
let _: Option<_> = try {
6271
let target = terminator.kind.as_goto()?;

0 commit comments

Comments
 (0)