diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index 7e7c5ceee93..430854974b3 100644 --- a/compiler/rustc_mir_build/src/builder/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -1940,10 +1940,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// in match tree lowering. fn merge_trivial_subcandidates(&mut self, candidate: &mut Candidate<'_, 'tcx>) { assert!(!candidate.subcandidates.is_empty()); - if candidate.false_edge_start_block.is_none() { - candidate.false_edge_start_block = candidate.subcandidates[0].false_edge_start_block; - } - if candidate.has_guard { // FIXME(or_patterns; matthewjasper) Don't give up if we have a guard. return; @@ -1963,6 +1959,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let or_span = candidate.or_span.take().unwrap(); let source_info = self.source_info(or_span); + if candidate.false_edge_start_block.is_none() { + candidate.false_edge_start_block = candidate.subcandidates[0].false_edge_start_block; + } + // Remove the (known-trivial) subcandidates from the candidate tree, // so that they aren't visible after match tree lowering, and wire them // all to join up at a single shared pre-binding block. @@ -1986,6 +1986,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { return; } + let false_edge_start_block = candidate.subcandidates[0].false_edge_start_block; candidate.subcandidates.retain_mut(|candidate| { if candidate.extra_data.is_never { candidate.visit_leaves(|subcandidate| { @@ -2004,6 +2005,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let next_block = self.cfg.start_new_block(); candidate.pre_binding_block = Some(next_block); candidate.otherwise_block = Some(next_block); + // In addition, if `candidate` should have `false_edge_start_block`. + if candidate.false_edge_start_block.is_none() { + candidate.false_edge_start_block = false_edge_start_block; + } } }