diff options
| author | matthewjasper <20113453+matthewjasper@users.noreply.github.com> | 2019-12-30 17:47:10 +0000 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2020-02-03 19:42:15 +0000 |
| commit | 1d90ed6370df81cb6e30816cb655c5a90af824a6 (patch) | |
| tree | bd0659de06a9632e6879771d6b31897dfbe70a50 | |
| parent | 89e52e2ca9e5bf63c197c2dfa7d062f409fbeec7 (diff) | |
| download | rust-1d90ed6370df81cb6e30816cb655c5a90af824a6.tar.gz rust-1d90ed6370df81cb6e30816cb655c5a90af824a6.zip | |
Apply suggestions from code review
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
| -rw-r--r-- | src/librustc_mir_build/build/matches/mod.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/or-patterns/basic-switchint.rs | 3 |
2 files changed, 5 insertions, 6 deletions
diff --git a/src/librustc_mir_build/build/matches/mod.rs b/src/librustc_mir_build/build/matches/mod.rs index d5ac2a14129..ed5d74f2e68 100644 --- a/src/librustc_mir_build/build/matches/mod.rs +++ b/src/librustc_mir_build/build/matches/mod.rs @@ -840,10 +840,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// (false, true) => (), /// } /// - /// 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 + /// 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 /// `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`. fn match_candidates<'pat>( &mut self, @@ -1104,6 +1104,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ) { 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 { PatKind::Or { .. } => (), _ => { diff --git a/src/test/ui/or-patterns/basic-switchint.rs b/src/test/ui/or-patterns/basic-switchint.rs index 2ae5f268165..c5a6d894eac 100644 --- a/src/test/ui/or-patterns/basic-switchint.rs +++ b/src/test/ui/or-patterns/basic-switchint.rs @@ -26,9 +26,6 @@ fn test_foo(x: Foo) -> MatchArm { // multiple or-patterns for one structure. Foo::Two(42 | 255, 1024 | 2048) => MatchArm::Arm(2), // 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), // multiple or-patterns with wild. Foo::Two(0..=10 | 100..=110, 0 | _) => MatchArm::Arm(4), |
