Skip to content

Commit b5ec4d1

Browse files
committed
Address reviews
1 parent 0030a77 commit b5ec4d1

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/librustc_mir/hair/pattern/_match.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ impl<'p, 'tcx> PatStack<'p, 'tcx> {
400400
}
401401

402402
// If the first pattern is an or-pattern, expand this pattern. Otherwise, return `None`.
403-
fn expand_or_pat(&self) -> Option<Vec<PatStack<'p, 'tcx>>> {
403+
fn expand_or_pat(&self) -> Option<Vec<Self>> {
404404
if self.is_empty() {
405405
None
406406
} else if let PatKind::Or { pats } = &*self.head().kind {
@@ -1838,7 +1838,7 @@ fn pat_constructor<'tcx>(
18381838
if slice.is_some() { VarLen(prefix, suffix) } else { FixedLen(prefix + suffix) };
18391839
Some(Slice(Slice { array_len, kind }))
18401840
}
1841-
PatKind::Or { .. } => bug!(), // Should have been expanded earlier on.
1841+
PatKind::Or { .. } => bug!("Or-pattern hould have been expanded earlier on."),
18421842
}
18431843
}
18441844

@@ -2444,7 +2444,7 @@ fn specialize_one_pattern<'p, 'a: 'p, 'q: 'p, 'tcx>(
24442444
_ => span_bug!(pat.span, "unexpected ctor {:?} for slice pat", constructor),
24452445
},
24462446

2447-
PatKind::Or { .. } => bug!(), // Should have been expanded earlier on.
2447+
PatKind::Or { .. } => bug!("Or-pattern hould have been expanded earlier on."),
24482448
};
24492449
debug!("specialize({:#?}, {:#?}) = {:#?}", pat, ctor_wild_subpatterns, result);
24502450

src/test/compile-fail/or-patterns.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// should-ice
2-
#![allow(incomplete_features)]
32
#![feature(or_patterns)]
3+
#![feature(slice_patterns)]
4+
#![allow(incomplete_features)]
45
#![deny(unreachable_patterns)]
56

67
// The ice will get removed once or-patterns are correctly implemented
@@ -53,4 +54,8 @@ fn main() {
5354
((1..=4,),) => {}, //~ ERROR unreachable pattern
5455
((_,),) => {},
5556
}
57+
match (&[0u8][..],) {
58+
([] | [0 | 1..=255] | [_, ..],) => {},
59+
(_,) => {}, //~ ERROR unreachable pattern
60+
}
5661
}

0 commit comments

Comments
 (0)