Skip to content

Commit 1240817

Browse files
simonvandelMark-Simulacrum
authored andcommitted
Fix miscompile in SimplifyBranchSame
1 parent 9eb4039 commit 1240817

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/librustc_mir/transform/simplify_try.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,8 @@ impl<'a, 'tcx> SimplifyBranchSameOptimizationFinder<'a, 'tcx> {
613613
// All successor basic blocks must be equal or contain statements that are pairwise considered equal.
614614
for ((bb_l_idx,bb_l), (bb_r_idx,bb_r)) in iter_bbs_reachable.tuple_windows() {
615615
let trivial_checks = bb_l.is_cleanup == bb_r.is_cleanup
616-
&& bb_l.terminator().kind == bb_r.terminator().kind;
616+
&& bb_l.terminator().kind == bb_r.terminator().kind
617+
&& bb_l.statements.len() == bb_r.statements.len();
617618
let statement_check = || {
618619
bb_l.statements.iter().zip(&bb_r.statements).try_fold(StatementEquality::TrivialEqual, |acc,(l,r)| {
619620
let stmt_equality = self.statement_equality(*adt_matched_on, &l, bb_l_idx, &r, bb_r_idx, self.tcx.sess.opts.debugging_opts.mir_opt_level);

0 commit comments

Comments
 (0)