Skip to content

Commit f8aaf9a

Browse files
committed
Disable ConstGoto opt in cleanup blocks
1 parent e187f88 commit f8aaf9a

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)