Only eat semicolons for statements that need them
When parsing a statement (e.g. inside a function body),
we now consider `struct Foo {};` and `$stmt;` to each consist
of two statements: `struct Foo {}` and `;`, and `$stmt` and `;`.
As a result, an attribute macro invoke as
`fn foo() { #[attr] struct Bar{}; }` will see `struct Bar{}` as its
input. Additionally, the 'unused semicolon' lint now fires in more
places.
This commit is contained in:
@@ -473,8 +473,7 @@ impl<'a> Parser<'a> {
|
||||
// so capture it
|
||||
add_semi_token(local.tokens.as_mut());
|
||||
}
|
||||
StmtKind::Empty => eat_semi = false,
|
||||
_ => {}
|
||||
StmtKind::Empty | StmtKind::Item(_) | StmtKind::Semi(_) => eat_semi = false,
|
||||
}
|
||||
|
||||
if eat_semi && self.eat(&token::Semi) {
|
||||
|
||||
Reference in New Issue
Block a user