Skip to content

Commit 1d90ed6

Browse files
Apply suggestions from code review
Co-Authored-By: Mazdak Farrokhzad <[email protected]>
1 parent 89e52e2 commit 1d90ed6

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/librustc_mir_build/build/matches/mod.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -840,10 +840,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
840840
/// (false, true) => (),
841841
/// }
842842
///
843-
/// For this match we check if `x.0` matches `true` (for the first
844-
/// arm) if that's false we check `x.1`, if it's `true` we check if
843+
/// For this match, we check if `x.0` matches `true` (for the first
844+
/// arm). If that's false, we check `x.1`. If it's `true` we check if
845845
/// `x.0` matches `false` (for the third arm). In the (impossible at
846-
/// runtime) case when `x.0` is now `true` we branch to
846+
/// runtime) case when `x.0` is now `true`, we branch to
847847
/// `otherwise_block`.
848848
fn match_candidates<'pat>(
849849
&mut self,
@@ -1104,6 +1104,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
11041104
) {
11051105
let (first_candidate, remaining_candidates) = candidates.split_first_mut().unwrap();
11061106

1107+
// All of the or-patterns have been sorted to the end, so if the first
1108+
// pattern is an or-pattern we only have or-patterns.
11071109
match *first_candidate.match_pairs[0].pattern.kind {
11081110
PatKind::Or { .. } => (),
11091111
_ => {

src/test/ui/or-patterns/basic-switchint.rs

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

0 commit comments

Comments
 (0)