Point at match when a parse failure ocurrs inside of it
This commit is contained in:
@@ -2474,7 +2474,11 @@ impl<'a> Parser<'a> {
|
|||||||
return Ok(self.mk_expr(lo.to(hi), ex, attrs));
|
return Ok(self.mk_expr(lo.to(hi), ex, attrs));
|
||||||
}
|
}
|
||||||
if self.eat_keyword(keywords::Match) {
|
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) {
|
if self.eat_keyword(keywords::Unsafe) {
|
||||||
return self.parse_block_expr(
|
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
|
--> $DIR/label_break_value_illegal_uses.rs:28:17
|
||||||
|
|
|
|
||||||
LL | match false 'b: {} //~ ERROR expected one of `.`, `?`, `{`, or an operator
|
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
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let foo =
|
let foo =
|
||||||
match
|
match //~ NOTE while parsing this match expression
|
||||||
Some(4).unwrap_or_else(5)
|
Some(4).unwrap_or_else(5)
|
||||||
//~^ NOTE expected one of `.`, `?`, `{`, or an operator here
|
//~^ NOTE expected one of `.`, `?`, `{`, or an operator here
|
||||||
; //~ NOTE unexpected token
|
; //~ NOTE unexpected token
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
error: expected one of `.`, `?`, `{`, or an operator, found `;`
|
error: expected one of `.`, `?`, `{`, or an operator, found `;`
|
||||||
--> $DIR/match-refactor-to-expr.rs:18:9
|
--> $DIR/match-refactor-to-expr.rs:18:9
|
||||||
|
|
|
|
||||||
LL | match
|
LL | match //~ NOTE while parsing this match expression
|
||||||
| ----- help: try removing this `match`
|
| -----
|
||||||
|
| |
|
||||||
|
| while parsing this match expression
|
||||||
|
| help: try removing this `match`
|
||||||
LL | Some(4).unwrap_or_else(5)
|
LL | Some(4).unwrap_or_else(5)
|
||||||
| - expected one of `.`, `?`, `{`, or an operator here
|
| - expected one of `.`, `?`, `{`, or an operator here
|
||||||
LL | //~^ NOTE 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
|
--> $DIR/try-block-in-match.rs:16:11
|
||||||
|
|
|
|
||||||
LL | match try { false } { _ => {} } //~ ERROR expected expression, found reserved keyword `try`
|
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
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user