diff --git a/src/librustc_mir/transform/simplify.rs b/src/librustc_mir/transform/simplify.rs index 9288d6e16f5..acf8c0181ce 100644 --- a/src/librustc_mir/transform/simplify.rs +++ b/src/librustc_mir/transform/simplify.rs @@ -212,6 +212,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> { Terminator { kind: TerminatorKind::Goto { ref mut target }, .. } => target, _ => unreachable!(), }; + *changed |= *target != last; *target = last; debug!("collapsing goto chain from {:?} to {:?}", current, target); @@ -223,7 +224,6 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> { self.pred_count[*target] += 1; self.pred_count[current] -= 1; } - *changed = true; self.basic_blocks[current].terminator = Some(terminator); } } diff --git a/src/test/ui/issues/issue-75704.rs b/src/test/ui/issues/issue-75704.rs new file mode 100644 index 00000000000..aed7ddbcb8c --- /dev/null +++ b/src/test/ui/issues/issue-75704.rs @@ -0,0 +1,7 @@ +// Caused an infinite loop during SimlifyCfg MIR transform previously. +// +// build-pass + +fn main() { + loop { continue; } +}