Group default cases in sort_candidate

This commit is contained in:
Nadrieril 2024-02-20 22:59:11 +01:00
parent 5e11a99bb6
commit f363c1a3fe

View File

@ -575,10 +575,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
fully_matched = true; fully_matched = true;
Some(variant_index.as_usize()) Some(variant_index.as_usize())
} }
(&TestKind::Switch { .. }, _) => {
fully_matched = false;
None
}
// If we are performing a switch over integers, then this informs integer // If we are performing a switch over integers, then this informs integer
// equality, but nothing else. // equality, but nothing else.
@ -603,10 +599,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
options.len() options.len()
}) })
} }
(&TestKind::SwitchInt { .. }, _) => {
fully_matched = false;
None
}
( (
&TestKind::Len { len: test_len, op: BinOp::Eq }, &TestKind::Len { len: test_len, op: BinOp::Eq },
@ -673,10 +665,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
} }
} }
} }
(TestKind::Len { .. }, _) => {
fully_matched = false;
None
}
(TestKind::Range(test), &TestCase::Range(pat)) => { (TestKind::Range(test), &TestCase::Range(pat)) => {
if test.as_ref() == pat { if test.as_ref() == pat {
@ -699,10 +687,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
None None
} }
} }
(&TestKind::Range { .. }, _) => {
fully_matched = false;
None
}
// FIXME(#29623): return `Some(1)` when the values are different. // FIXME(#29623): return `Some(1)` when the values are different.
(TestKind::Eq { value: test_val, .. }, TestCase::Constant { value: case_val }) (TestKind::Eq { value: test_val, .. }, TestCase::Constant { value: case_val })
@ -711,7 +695,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
fully_matched = true; fully_matched = true;
Some(0) Some(0)
} }
(TestKind::Eq { .. }, _) => {
(
TestKind::Switch { .. }
| TestKind::SwitchInt { .. }
| TestKind::Len { .. }
| TestKind::Range { .. }
| TestKind::Eq { .. },
_,
) => {
fully_matched = false; fully_matched = false;
None None
} }