@@ -1585,18 +1585,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
15851585 // We could add them to the or-candidates before the call to `test_or_pattern` but this
15861586 // would make it impossible to detect simplifiable or-patterns. That would guarantee
15871587 // exponentially large CFGs for cases like `(1 | 2, 3 | 4, ...)`.
1588+ let mut last_otherwise = None ;
1589+ first_candidate. visit_leaves ( |leaf_candidate| {
1590+ last_otherwise = leaf_candidate. otherwise_block ;
1591+ } ) ;
15881592 first_candidate. visit_leaves ( |leaf_candidate| {
15891593 assert ! ( leaf_candidate. match_pairs. is_empty( ) ) ;
15901594 leaf_candidate. match_pairs . extend ( remaining_match_pairs. iter ( ) . cloned ( ) ) ;
15911595 let or_start = leaf_candidate. pre_binding_block . unwrap ( ) ;
15921596 // In a case like `(P | Q, R | S)`, if `P` succeeds and `R | S` fails, we know `(Q,
15931597 // R | S)` will fail too. If there is no guard, we skip testing of `Q` by branching
1594- // directly to `remainder_start`. If there is a guard, `or_otherwise` can be reached
1595- // by guard failure as well, so we can't skip `Q`.
1598+ // directly to `last_otherwise`. If there is a guard,
1599+ // `leaf_candidate.otherwise_block` can be reached by guard failure as well, so we
1600+ // can't skip `Q`.
15961601 let or_otherwise = if leaf_candidate. has_guard {
15971602 leaf_candidate. otherwise_block . unwrap ( )
15981603 } else {
1599- remainder_start
1604+ last_otherwise . unwrap ( )
16001605 } ;
16011606 self . test_candidates_with_or (
16021607 span,
0 commit comments