Point at match
when a parse failure ocurrs inside of it
This commit is contained in:
parent
ea57134607
commit
d491734b15
5 changed files with 17 additions and 6 deletions
|
@ -2474,7 +2474,11 @@ impl<'a> Parser<'a> {
|
|||
return Ok(self.mk_expr(lo.to(hi), ex, attrs));
|
||||
}
|
||||
if self.eat_keyword(keywords::Match) {
|
||||
return self.parse_match_expr(attrs);
|
||||
let match_sp = self.prev_span;
|
||||
return self.parse_match_expr(attrs).map_err(|mut err| {
|
||||
err.span_label(match_sp, "while parsing this match expression");
|
||||
err
|
||||
});
|
||||
}
|
||||
if self.eat_keyword(keywords::Unsafe) {
|
||||
return self.parse_block_expr(
|
||||
|
|
|
@ -25,7 +25,9 @@ error: expected one of `.`, `?`, `{`, or an operator, found `'b`
|
|||
--> $DIR/label_break_value_illegal_uses.rs:28:17
|
||||
|
|
||||
LL | match false 'b: {} //~ ERROR expected one of `.`, `?`, `{`, or an operator
|
||||
| ^^ expected one of `.`, `?`, `{`, or an operator here
|
||||
| ----- ^^ expected one of `.`, `?`, `{`, or an operator here
|
||||
| |
|
||||
| while parsing this match expression
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
fn main() {
|
||||
let foo =
|
||||
match
|
||||
match //~ NOTE while parsing this match expression
|
||||
Some(4).unwrap_or_else(5)
|
||||
//~^ NOTE expected one of `.`, `?`, `{`, or an operator here
|
||||
; //~ NOTE unexpected token
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
error: expected one of `.`, `?`, `{`, or an operator, found `;`
|
||||
--> $DIR/match-refactor-to-expr.rs:18:9
|
||||
|
|
||||
LL | match
|
||||
| ----- help: try removing this `match`
|
||||
LL | match //~ NOTE while parsing this match expression
|
||||
| -----
|
||||
| |
|
||||
| while parsing this match expression
|
||||
| help: try removing this `match`
|
||||
LL | Some(4).unwrap_or_else(5)
|
||||
| - expected one of `.`, `?`, `{`, or an operator here
|
||||
LL | //~^ NOTE expected one of `.`, `?`, `{`, or an operator here
|
||||
|
|
|
@ -2,7 +2,9 @@ error: expected expression, found reserved keyword `try`
|
|||
--> $DIR/try-block-in-match.rs:16:11
|
||||
|
|
||||
LL | match try { false } { _ => {} } //~ ERROR expected expression, found reserved keyword `try`
|
||||
| ^^^ expected expression
|
||||
| ----- ^^^ expected expression
|
||||
| |
|
||||
| while parsing this match expression
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue