Skip to content

Commit f363c1a

Browse files
committed
Group default cases in sort_candidate
1 parent 5e11a99 commit f363c1a

File tree

1 file changed

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

1 file changed

+9
-17
lines changed

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

+9-17
Original file line numberDiff line numberDiff line change
@@ -575,10 +575,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
575575
fully_matched = true;
576576
Some(variant_index.as_usize())
577577
}
578-
(&TestKind::Switch { .. }, _) => {
579-
fully_matched = false;
580-
None
581-
}
582578

583579
// If we are performing a switch over integers, then this informs integer
584580
// equality, but nothing else.
@@ -603,10 +599,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
603599
options.len()
604600
})
605601
}
606-
(&TestKind::SwitchInt { .. }, _) => {
607-
fully_matched = false;
608-
None
609-
}
610602

611603
(
612604
&TestKind::Len { len: test_len, op: BinOp::Eq },
@@ -673,10 +665,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
673665
}
674666
}
675667
}
676-
(TestKind::Len { .. }, _) => {
677-
fully_matched = false;
678-
None
679-
}
680668

681669
(TestKind::Range(test), &TestCase::Range(pat)) => {
682670
if test.as_ref() == pat {
@@ -699,10 +687,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
699687
None
700688
}
701689
}
702-
(&TestKind::Range { .. }, _) => {
703-
fully_matched = false;
704-
None
705-
}
706690

707691
// FIXME(#29623): return `Some(1)` when the values are different.
708692
(TestKind::Eq { value: test_val, .. }, TestCase::Constant { value: case_val })
@@ -711,7 +695,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
711695
fully_matched = true;
712696
Some(0)
713697
}
714-
(TestKind::Eq { .. }, _) => {
698+
699+
(
700+
TestKind::Switch { .. }
701+
| TestKind::SwitchInt { .. }
702+
| TestKind::Len { .. }
703+
| TestKind::Range { .. }
704+
| TestKind::Eq { .. },
705+
_,
706+
) => {
715707
fully_matched = false;
716708
None
717709
}

0 commit comments

Comments
 (0)