parser: 'while parsing this or-pattern...'

This commit is contained in:
Mazdak Farrokhzad 2019-08-25 01:50:21 +02:00
parent 1202cb0e2b
commit 083963e58c
3 changed files with 23 additions and 1 deletions

View File

@ -81,7 +81,10 @@ fn parse_pat_with_or(&mut self, gate_or: GateOr, top_level: TopLevel) -> PResult
let lo = first_pat.span;
let mut pats = vec![first_pat];
while self.eat_or_separator() {
let pat = self.parse_pat(None)?;
let pat = self.parse_pat(None).map_err(|mut err| {
err.span_label(lo, "while parsing this or-pattern staring here");
err
})?;
self.maybe_recover_unexpected_comma(pat.span, top_level)?;
pats.push(pat);
}

View File

@ -0,0 +1,9 @@
// Test the parser for the "while parsing this or-pattern..." label here.
fn main() {
match Some(42) {
Some(42) | .=. => {} //~ ERROR expected pattern, found `.`
//~^ while parsing this or-pattern staring here
//~| NOTE expected pattern
}
}

View File

@ -0,0 +1,10 @@
error: expected pattern, found `.`
--> $DIR/while-parsing-this-or-pattern.rs:5:20
|
LL | Some(42) | .=. => {}
| -------- ^ expected pattern
| |
| while parsing this or-pattern staring here
error: aborting due to previous error