Point at match when a parse failure ocurrs inside of it

This commit is contained in:
Esteban Küber
2018-10-28 11:41:23 -07:00
parent ea57134607
commit d491734b15
5 changed files with 17 additions and 6 deletions

View File

@@ -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(