Do not add ; to expected tokens list when it's wrong

There's a few spots where semicolons are checked for to do error recovery,
and should not be suggested (or checked for other stuff).

Fixes #87647
This commit is contained in:
Michael Howell
2021-12-04 11:05:30 -07:00
parent 532d2b14c0
commit 74437e477e
16 changed files with 90 additions and 51 deletions

View File

@@ -1129,7 +1129,8 @@ impl<'a> Parser<'a> {
}
pub fn maybe_consume_incorrect_semicolon(&mut self, items: &[P<Item>]) -> bool {
if self.eat(&token::Semi) {
if self.token.kind == TokenKind::Semi {
self.bump();
let mut err = self.struct_span_err(self.prev_token.span, "expected item, found `;`");
err.span_suggestion_short(
self.prev_token.span,