Skip to content

Commit 96b0807

Browse files
committed
Inline finalize_or_candidate
1 parent 9c09cb4 commit 96b0807

File tree

1 file changed

+7
-17
lines changed
  • compiler/rustc_mir_build/src/build/matches

1 file changed

+7
-17
lines changed

compiler/rustc_mir_build/src/build/matches/mod.rs

+7-17
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
16241624
});
16251625
for candidate in candidates_to_expand.iter_mut() {
16261626
if !candidate.subcandidates.is_empty() {
1627-
self.finalize_or_candidate(candidate);
1627+
self.merge_trivial_subcandidates(candidate);
1628+
self.remove_never_subcandidates(candidate);
16281629
}
16291630
}
16301631
if let Some(last_candidate) = candidates_to_expand.last_mut() {
@@ -1635,8 +1636,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
16351636
}
16361637

16371638
/// Given a match-pair that corresponds to an or-pattern, expand each subpattern into a new
1638-
/// subcandidate. Any candidate that has been expanded that way should be passed to
1639-
/// `finalize_or_candidate` after its subcandidates have been processed.
1639+
/// subcandidate. Any candidate that has been expanded this way should also be postprocessed
1640+
/// at the end of [`Self::expand_and_match_or_candidates`].
16401641
fn create_or_subcandidates<'pat>(
16411642
&mut self,
16421643
candidate: &mut Candidate<'pat, 'tcx>,
@@ -1653,8 +1654,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
16531654
candidate.subcandidates[0].false_edge_start_block = candidate.false_edge_start_block;
16541655
}
16551656

1656-
/// Simplify subcandidates and remove `is_never` subcandidates.
1657-
/// The candidate should have been expanded with `create_or_subcandidates`.
1657+
/// Try to merge all of the subcandidates of the given candidate into one. This avoids
1658+
/// exponentially large CFGs in cases like `(1 | 2, 3 | 4, ...)`. The candidate should have been
1659+
/// expanded with `create_or_subcandidates`.
16581660
///
16591661
/// Given a pattern `(P | Q, R | S)` we (in principle) generate a CFG like
16601662
/// so:
@@ -1706,18 +1708,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
17061708
/// |
17071709
/// ...
17081710
/// ```
1709-
fn finalize_or_candidate(&mut self, candidate: &mut Candidate<'_, 'tcx>) {
1710-
if candidate.subcandidates.is_empty() {
1711-
return;
1712-
}
1713-
1714-
self.merge_trivial_subcandidates(candidate);
1715-
self.remove_never_subcandidates(candidate);
1716-
}
1717-
1718-
/// Try to merge all of the subcandidates of the given candidate into one. This avoids
1719-
/// exponentially large CFGs in cases like `(1 | 2, 3 | 4, ...)`. The candidate should have been
1720-
/// expanded with `create_or_subcandidates`.
17211711
///
17221712
/// Note that this takes place _after_ the subcandidates have participated
17231713
/// in match tree lowering.

0 commit comments

Comments
 (0)