diff options
| author | Aaron Hill <aa1ronham@gmail.com> | 2020-11-25 16:52:24 -0500 |
|---|---|---|
| committer | Aaron Hill <aa1ronham@gmail.com> | 2020-11-26 17:08:35 -0500 |
| commit | 758834d3e2b2589f73b62df386780c8096ed7ae1 (patch) | |
| tree | 6842676a02f7c1a941aa9c6df3be0ea697b42be3 /compiler/rustc_parse/src/parser | |
| parent | de88bf148b122b27ce48a4a6679c41c834d33019 (diff) | |
| download | rust-758834d3e2b2589f73b62df386780c8096ed7ae1.tar.gz rust-758834d3e2b2589f73b62df386780c8096ed7ae1.zip | |
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.
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/stmt.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index b41aba9b627..e974556f43a 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -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) { |
