Rollup merge of #100565 - TaKO8Ki:suggest-adding-missing-semicolon-before-item, r=compiler-errors

Suggest adding a missing semicolon before an item

fixes #100533
This commit is contained in:
Matthias Krüger 2022-08-23 06:55:24 +02:00 committed by GitHub
commit 54d0f50677
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 233 additions and 2 deletions

View file

@ -927,10 +927,12 @@ impl<'a> Parser<'a> {
return Ok(true);
} else if self.look_ahead(0, |t| {
t == &token::CloseDelim(Delimiter::Brace)
|| (t.can_begin_expr() && t != &token::Semi && t != &token::Pound)
|| ((t.can_begin_expr() || t.can_begin_item())
&& t != &token::Semi
&& t != &token::Pound)
// Avoid triggering with too many trailing `#` in raw string.
|| (sm.is_multiline(
self.prev_token.span.shrink_to_hi().until(self.token.span.shrink_to_lo())
self.prev_token.span.shrink_to_hi().until(self.token.span.shrink_to_lo()),
) && t == &token::Pound)
}) && !expected.contains(&TokenType::Token(token::Comma))
{