@@ -1624,7 +1624,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1624
1624
} ) ;
1625
1625
for candidate in candidates_to_expand. iter_mut ( ) {
1626
1626
if !candidate. subcandidates . is_empty ( ) {
1627
- self . finalize_or_candidate ( candidate) ;
1627
+ self . merge_trivial_subcandidates ( candidate) ;
1628
+ self . remove_never_subcandidates ( candidate) ;
1628
1629
}
1629
1630
}
1630
1631
if let Some ( last_candidate) = candidates_to_expand. last_mut ( ) {
@@ -1635,8 +1636,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1635
1636
}
1636
1637
1637
1638
/// 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`] .
1640
1641
fn create_or_subcandidates < ' pat > (
1641
1642
& mut self ,
1642
1643
candidate : & mut Candidate < ' pat , ' tcx > ,
@@ -1653,8 +1654,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1653
1654
candidate. subcandidates [ 0 ] . false_edge_start_block = candidate. false_edge_start_block ;
1654
1655
}
1655
1656
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`.
1658
1660
///
1659
1661
/// Given a pattern `(P | Q, R | S)` we (in principle) generate a CFG like
1660
1662
/// so:
@@ -1706,18 +1708,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1706
1708
/// |
1707
1709
/// ...
1708
1710
/// ```
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`.
1721
1711
///
1722
1712
/// Note that this takes place _after_ the subcandidates have participated
1723
1713
/// in match tree lowering.
0 commit comments