Skip to content

Commit 5bf50e6

Browse files
committed
Move a function
1 parent 9dcaa7f commit 5bf50e6

File tree

1 file changed

+19
-19
lines changed
  • compiler/rustc_mir_build/src/build/matches

1 file changed

+19
-19
lines changed

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

+19-19
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,25 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
16241624
otherwise_block
16251625
}
16261626

1627+
/// Given a match-pair that corresponds to an or-pattern, expand each subpattern into a new
1628+
/// subcandidate. Any candidate that has been expanded that way should be passed to
1629+
/// `finalize_or_candidate` after its subcandidates have been processed.
1630+
fn create_or_subcandidates<'pat>(
1631+
&mut self,
1632+
candidate: &mut Candidate<'pat, 'tcx>,
1633+
match_pair: MatchPair<'pat, 'tcx>,
1634+
) {
1635+
let TestCase::Or { pats } = match_pair.test_case else { bug!() };
1636+
debug!("expanding or-pattern: candidate={:#?}\npats={:#?}", candidate, pats);
1637+
candidate.or_span = Some(match_pair.pattern.span);
1638+
candidate.subcandidates = pats
1639+
.into_vec()
1640+
.into_iter()
1641+
.map(|flat_pat| Candidate::from_flat_pat(flat_pat, candidate.has_guard))
1642+
.collect();
1643+
candidate.subcandidates[0].false_edge_start_block = candidate.false_edge_start_block;
1644+
}
1645+
16271646
/// Simplify subcandidates and process any leftover match pairs. The candidate should have been
16281647
/// expanded with `create_or_subcandidates`.
16291648
///
@@ -1724,25 +1743,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
17241743
}
17251744
}
17261745

1727-
/// Given a match-pair that corresponds to an or-pattern, expand each subpattern into a new
1728-
/// subcandidate. Any candidate that has been expanded that way should be passed to
1729-
/// `finalize_or_candidate` after its subcandidates have been processed.
1730-
fn create_or_subcandidates<'pat>(
1731-
&mut self,
1732-
candidate: &mut Candidate<'pat, 'tcx>,
1733-
match_pair: MatchPair<'pat, 'tcx>,
1734-
) {
1735-
let TestCase::Or { pats } = match_pair.test_case else { bug!() };
1736-
debug!("expanding or-pattern: candidate={:#?}\npats={:#?}", candidate, pats);
1737-
candidate.or_span = Some(match_pair.pattern.span);
1738-
candidate.subcandidates = pats
1739-
.into_vec()
1740-
.into_iter()
1741-
.map(|flat_pat| Candidate::from_flat_pat(flat_pat, candidate.has_guard))
1742-
.collect();
1743-
candidate.subcandidates[0].false_edge_start_block = candidate.false_edge_start_block;
1744-
}
1745-
17461746
/// Try to merge all of the subcandidates of the given candidate into one. This avoids
17471747
/// exponentially large CFGs in cases like `(1 | 2, 3 | 4, ...)`. The candidate should have been
17481748
/// expanded with `create_or_subcandidates`.

0 commit comments

Comments
 (0)