mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 20:23:59 +00:00
parser: use eat_or_separator
for leading vert.
This commit is contained in:
parent
dc5bbaf7b2
commit
6498959377
@ -22,8 +22,8 @@ impl<'a> Parser<'a> {
|
||||
|
||||
/// Parses patterns, separated by '|' s.
|
||||
pub(super) fn parse_pats(&mut self) -> PResult<'a, Vec<P<Pat>>> {
|
||||
// Allow a '|' before the pats (RFC 1925 + RFC 2530)
|
||||
self.eat(&token::BinOp(token::Or));
|
||||
// Allow a '|' before the pats (RFCs 1925, 2530, and 2535).
|
||||
self.eat_or_separator();
|
||||
|
||||
let mut pats = Vec::new();
|
||||
loop {
|
||||
|
@ -37,4 +37,9 @@ fn main() {
|
||||
[1 | 2 || 3] => (), //~ ERROR unexpected token `||` after pattern
|
||||
_ => (),
|
||||
}
|
||||
|
||||
match x {
|
||||
|| 1 | 2 | 3 => (), //~ ERROR unexpected token `||` after pattern
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,12 @@ error: unexpected token `||` after pattern
|
||||
LL | [1 | 2 || 3] => (),
|
||||
| ^^ help: use a single `|` to specify multiple patterns: `|`
|
||||
|
||||
error: unexpected token `||` after pattern
|
||||
--> $DIR/multiple-pattern-typo.rs:42:9
|
||||
|
|
||||
LL | || 1 | 2 | 3 => (),
|
||||
| ^^ help: use a single `|` to specify multiple patterns: `|`
|
||||
|
||||
warning: the feature `or_patterns` is incomplete and may cause the compiler to crash
|
||||
--> $DIR/multiple-pattern-typo.rs:1:12
|
||||
|
|
||||
@ -42,5 +48,5 @@ LL | #![feature(or_patterns)]
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user