Skip to content

Commit 6498959

Browse files
committed
parser: use eat_or_separator for leading vert.
1 parent dc5bbaf commit 6498959

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/libsyntax/parse/parser/pat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ impl<'a> Parser<'a> {
2222

2323
/// Parses patterns, separated by '|' s.
2424
pub(super) fn parse_pats(&mut self) -> PResult<'a, Vec<P<Pat>>> {
25-
// Allow a '|' before the pats (RFC 1925 + RFC 2530)
26-
self.eat(&token::BinOp(token::Or));
25+
// Allow a '|' before the pats (RFCs 1925, 2530, and 2535).
26+
self.eat_or_separator();
2727

2828
let mut pats = Vec::new();
2929
loop {

src/test/ui/or-patterns/multiple-pattern-typo.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,9 @@ fn main() {
3737
[1 | 2 || 3] => (), //~ ERROR unexpected token `||` after pattern
3838
_ => (),
3939
}
40+
41+
match x {
42+
|| 1 | 2 | 3 => (), //~ ERROR unexpected token `||` after pattern
43+
_ => (),
44+
}
4045
}

src/test/ui/or-patterns/multiple-pattern-typo.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ error: unexpected token `||` after pattern
3434
LL | [1 | 2 || 3] => (),
3535
| ^^ help: use a single `|` to specify multiple patterns: `|`
3636

37+
error: unexpected token `||` after pattern
38+
--> $DIR/multiple-pattern-typo.rs:42:9
39+
|
40+
LL | || 1 | 2 | 3 => (),
41+
| ^^ help: use a single `|` to specify multiple patterns: `|`
42+
3743
warning: the feature `or_patterns` is incomplete and may cause the compiler to crash
3844
--> $DIR/multiple-pattern-typo.rs:1:12
3945
|
@@ -42,5 +48,5 @@ LL | #![feature(or_patterns)]
4248
|
4349
= note: `#[warn(incomplete_features)]` on by default
4450

45-
error: aborting due to 6 previous errors
51+
error: aborting due to 7 previous errors
4652

0 commit comments

Comments
 (0)