Rename test to pick_test_for_match_pair

This commit is contained in:
Zalathar 2024-07-17 21:41:42 +10:00
parent 03bfa3690e
commit 411fcb6b2d
2 changed files with 6 additions and 3 deletions

View File

@ -1809,8 +1809,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
/// [`Range`]: TestKind::Range /// [`Range`]: TestKind::Range
fn pick_test(&mut self, candidates: &[&mut Candidate<'_, 'tcx>]) -> (Place<'tcx>, Test<'tcx>) { fn pick_test(&mut self, candidates: &[&mut Candidate<'_, 'tcx>]) -> (Place<'tcx>, Test<'tcx>) {
// Extract the match-pair from the highest priority candidate // Extract the match-pair from the highest priority candidate
let match_pair = &candidates.first().unwrap().match_pairs[0]; let match_pair = &candidates[0].match_pairs[0];
let test = self.test(match_pair); let test = self.pick_test_for_match_pair(match_pair);
// Unwrap is ok after simplification. // Unwrap is ok after simplification.
let match_place = match_pair.place.unwrap(); let match_place = match_pair.place.unwrap();
debug!(?test, ?match_pair); debug!(?test, ?match_pair);

View File

@ -26,7 +26,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
/// Identifies what test is needed to decide if `match_pair` is applicable. /// Identifies what test is needed to decide if `match_pair` is applicable.
/// ///
/// It is a bug to call this with a not-fully-simplified pattern. /// It is a bug to call this with a not-fully-simplified pattern.
pub(super) fn test<'pat>(&mut self, match_pair: &MatchPairTree<'pat, 'tcx>) -> Test<'tcx> { pub(super) fn pick_test_for_match_pair<'pat>(
&mut self,
match_pair: &MatchPairTree<'pat, 'tcx>,
) -> Test<'tcx> {
let kind = match match_pair.test_case { let kind = match match_pair.test_case {
TestCase::Variant { adt_def, variant_index: _ } => TestKind::Switch { adt_def }, TestCase::Variant { adt_def, variant_index: _ } => TestKind::Switch { adt_def },