1
Fork 0

Apply suggestions from code review

Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
This commit is contained in:
matthewjasper 2019-12-30 17:47:10 +00:00 committed by Matthew Jasper
parent 89e52e2ca9
commit 1d90ed6370
2 changed files with 5 additions and 6 deletions

View file

@ -840,10 +840,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
/// (false, true) => (), /// (false, true) => (),
/// } /// }
/// ///
/// For this match we check if `x.0` matches `true` (for the first /// For this match, we check if `x.0` matches `true` (for the first
/// arm) if that's false we check `x.1`, if it's `true` we check if /// arm). If that's false, we check `x.1`. If it's `true` we check if
/// `x.0` matches `false` (for the third arm). In the (impossible at /// `x.0` matches `false` (for the third arm). In the (impossible at
/// runtime) case when `x.0` is now `true` we branch to /// runtime) case when `x.0` is now `true`, we branch to
/// `otherwise_block`. /// `otherwise_block`.
fn match_candidates<'pat>( fn match_candidates<'pat>(
&mut self, &mut self,
@ -1104,6 +1104,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
) { ) {
let (first_candidate, remaining_candidates) = candidates.split_first_mut().unwrap(); let (first_candidate, remaining_candidates) = candidates.split_first_mut().unwrap();
// All of the or-patterns have been sorted to the end, so if the first
// pattern is an or-pattern we only have or-patterns.
match *first_candidate.match_pairs[0].pattern.kind { match *first_candidate.match_pairs[0].pattern.kind {
PatKind::Or { .. } => (), PatKind::Or { .. } => (),
_ => { _ => {

View file

@ -26,9 +26,6 @@ fn test_foo(x: Foo) -> MatchArm {
// multiple or-patterns for one structure. // multiple or-patterns for one structure.
Foo::Two(42 | 255, 1024 | 2048) => MatchArm::Arm(2), Foo::Two(42 | 255, 1024 | 2048) => MatchArm::Arm(2),
// mix of pattern types in one or-pattern (range). // mix of pattern types in one or-pattern (range).
//
// FIXME(dlrobertson | Nadrieril): Fix or-pattern completeness and
// unreachabilitychecks for ranges.
Foo::One(100 | 110..=120 | 210..=220) => MatchArm::Arm(3), Foo::One(100 | 110..=120 | 210..=220) => MatchArm::Arm(3),
// multiple or-patterns with wild. // multiple or-patterns with wild.
Foo::Two(0..=10 | 100..=110, 0 | _) => MatchArm::Arm(4), Foo::Two(0..=10 | 100..=110, 0 | _) => MatchArm::Arm(4),