diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index 6d083e66a9b..0fb5ed89437 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -1299,7 +1299,7 @@ fn match_candidates<'pat>( for candidate in candidates.iter_mut() { candidate.visit_leaves(|leaf_candidate| new_candidates.push(leaf_candidate)); } - self.match_simplified_candidates( + self.match_candidates( span, scrutinee_span, start_block, @@ -1556,11 +1556,7 @@ fn merge_trivial_subcandidates(&mut self, candidate: &mut Candidate<'_, 'tcx>) { } let mut can_merge = true; - - // Not `Iterator::all` because we don't want to short-circuit. for subcandidate in &mut candidate.subcandidates { - self.merge_trivial_subcandidates(subcandidate); - // FIXME(or_patterns; matthewjasper) Try to be more aggressive here. can_merge &= subcandidate.subcandidates.is_empty() && subcandidate.extra_data.is_empty(); diff --git a/compiler/rustc_mir_build/src/build/matches/simplify.rs b/compiler/rustc_mir_build/src/build/matches/simplify.rs index bf1906f370b..0c4d45ea050 100644 --- a/compiler/rustc_mir_build/src/build/matches/simplify.rs +++ b/compiler/rustc_mir_build/src/build/matches/simplify.rs @@ -67,26 +67,12 @@ pub(super) fn simplify_match_pairs<'pat>( debug!(simplified = ?match_pairs, "simplify_match_pairs"); } - /// Create a new candidate for each pattern in `pats`, and recursively simplify tje - /// single-or-pattern case. + /// Create a new candidate for each pattern in `pats`. pub(super) fn create_or_subcandidates<'pat>( &mut self, pats: &[FlatPat<'pat, 'tcx>], has_guard: bool, ) -> Vec> { - pats.iter() - .cloned() - .map(|flat_pat| { - let mut candidate = Candidate::from_flat_pat(flat_pat, has_guard); - if let [MatchPair { test_case: TestCase::Or { pats, .. }, .. }] = - &*candidate.match_pairs - { - candidate.subcandidates = self.create_or_subcandidates(pats, has_guard); - let first_match_pair = candidate.match_pairs.pop().unwrap(); - candidate.or_span = Some(first_match_pair.pattern.span); - } - candidate - }) - .collect() + pats.iter().cloned().map(|flat_pat| Candidate::from_flat_pat(flat_pat, has_guard)).collect() } }