1
Fork 0

Remove spurious complaint about missing expression for bare semicolons

This commit is contained in:
Esteban Küber 2019-02-05 02:25:06 -08:00
parent 99be87aac3
commit 1495d30448
3 changed files with 27 additions and 9 deletions

View file

@ -731,7 +731,7 @@ impl<'a> Parser<'a> {
Applicability::MaybeIncorrect,
);
err.emit();
// self.expected_tokens.clear(); // reduce errors
self.expected_tokens.clear(); // reduce errors
Ok(true)
}
_ => Err(err),
@ -2814,6 +2814,21 @@ impl<'a> Parser<'a> {
hi = pth.span;
ex = ExprKind::Path(None, pth);
} else {
if !self.unclosed_delims.is_empty() && self.check(&token::Semi) {
// Don't complain about bare semicolons after unclosed braces
// recovery in order to keep the error count down. Fixing the
// delimiters will possibly also fix the bare semicolon found in
// expression context. For example, silence the following error:
// ```
// error: expected expression, found `;`
// --> file.rs:2:13
// |
// 2 | foo(bar(;
// | ^ expected expression
// ```
self.bump();
return Ok(self.mk_expr(self.span, ExprKind::Err, ThinVec::new()));
}
match self.parse_literal_maybe_minus() {
Ok(expr) => {
hi = expr.span;