Skip to content

Commit 64692d4

Browse files
committed
Move a function
1 parent 2af3bba commit 64692d4

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
@@ -1561,6 +1561,25 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
15611561
otherwise_block
15621562
}
15631563

1564+
/// Given a match-pair that corresponds to an or-pattern, expand each subpattern into a new
1565+
/// subcandidate. Any candidate that has been expanded that way should be passed to
1566+
/// `finalize_or_candidate` after its subcandidates have been processed.
1567+
fn create_or_subcandidates<'pat>(
1568+
&mut self,
1569+
candidate: &mut Candidate<'pat, 'tcx>,
1570+
match_pair: MatchPair<'pat, 'tcx>,
1571+
) {
1572+
let TestCase::Or { pats } = match_pair.test_case else { bug!() };
1573+
debug!("expanding or-pattern: candidate={:#?}\npats={:#?}", candidate, pats);
1574+
candidate.or_span = Some(match_pair.pattern.span);
1575+
candidate.subcandidates = pats
1576+
.into_vec()
1577+
.into_iter()
1578+
.map(|flat_pat| Candidate::from_flat_pat(flat_pat, candidate.has_guard))
1579+
.collect();
1580+
candidate.subcandidates[0].false_edge_start_block = candidate.false_edge_start_block;
1581+
}
1582+
15641583
/// Simplify subcandidates and process any leftover match pairs. The candidate should have been
15651584
/// expanded with `create_or_subcandidates`.
15661585
///
@@ -1661,25 +1680,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
16611680
}
16621681
}
16631682

1664-
/// Given a match-pair that corresponds to an or-pattern, expand each subpattern into a new
1665-
/// subcandidate. Any candidate that has been expanded that way should be passed to
1666-
/// `finalize_or_candidate` after its subcandidates have been processed.
1667-
fn create_or_subcandidates<'pat>(
1668-
&mut self,
1669-
candidate: &mut Candidate<'pat, 'tcx>,
1670-
match_pair: MatchPair<'pat, 'tcx>,
1671-
) {
1672-
let TestCase::Or { pats } = match_pair.test_case else { bug!() };
1673-
debug!("expanding or-pattern: candidate={:#?}\npats={:#?}", candidate, pats);
1674-
candidate.or_span = Some(match_pair.pattern.span);
1675-
candidate.subcandidates = pats
1676-
.into_vec()
1677-
.into_iter()
1678-
.map(|flat_pat| Candidate::from_flat_pat(flat_pat, candidate.has_guard))
1679-
.collect();
1680-
candidate.subcandidates[0].false_edge_start_block = candidate.false_edge_start_block;
1681-
}
1682-
16831683
/// Try to merge all of the subcandidates of the given candidate into one. This avoids
16841684
/// exponentially large CFGs in cases like `(1 | 2, 3 | 4, ...)`. The candidate should have been
16851685
/// expanded with `create_or_subcandidates`.

0 commit comments

Comments
 (0)