Skip to content

Commit 083963e

Browse files
committed
parser: 'while parsing this or-pattern...'
1 parent 1202cb0 commit 083963e

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/libsyntax/parse/parser/pat.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ impl<'a> Parser<'a> {
8181
let lo = first_pat.span;
8282
let mut pats = vec![first_pat];
8383
while self.eat_or_separator() {
84-
let pat = self.parse_pat(None)?;
84+
let pat = self.parse_pat(None).map_err(|mut err| {
85+
err.span_label(lo, "while parsing this or-pattern staring here");
86+
err
87+
})?;
8588
self.maybe_recover_unexpected_comma(pat.span, top_level)?;
8689
pats.push(pat);
8790
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Test the parser for the "while parsing this or-pattern..." label here.
2+
3+
fn main() {
4+
match Some(42) {
5+
Some(42) | .=. => {} //~ ERROR expected pattern, found `.`
6+
//~^ while parsing this or-pattern staring here
7+
//~| NOTE expected pattern
8+
}
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: expected pattern, found `.`
2+
--> $DIR/while-parsing-this-or-pattern.rs:5:20
3+
|
4+
LL | Some(42) | .=. => {}
5+
| -------- ^ expected pattern
6+
| |
7+
| while parsing this or-pattern staring here
8+
9+
error: aborting due to previous error
10+

0 commit comments

Comments
 (0)