parser: 'while parsing this or-pattern...'
This commit is contained in:
parent
1202cb0e2b
commit
083963e58c
@ -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);
|
||||
}
|
||||
|
9
src/test/ui/or-patterns/while-parsing-this-or-pattern.rs
Normal file
9
src/test/ui/or-patterns/while-parsing-this-or-pattern.rs
Normal 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
|
||||
}
|
||||
}
|
10
src/test/ui/or-patterns/while-parsing-this-or-pattern.stderr
Normal file
10
src/test/ui/or-patterns/while-parsing-this-or-pattern.stderr
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user