diff options
| author | Michael Goulet <michael@errs.io> | 2022-08-13 14:10:12 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-13 14:10:12 -0700 |
| commit | 29f905bfafed0c6821f4973287593803fa033b80 (patch) | |
| tree | ccd7af0f0bf00840bb0f51f0f6bb40fb27c9484d /compiler/rustc_parse | |
| parent | 7a34d392787473f62dda3028a2c94fa88cc71c70 (diff) | |
| parent | 52a15180d2bc193aceea7302dd175f2c872df340 (diff) | |
| download | rust-29f905bfafed0c6821f4973287593803fa033b80.tar.gz rust-29f905bfafed0c6821f4973287593803fa033b80.zip | |
Rollup merge of #100475 - chenyukang:fix-100461, r=fee1-dead
Give a helpful diagnostic when the next struct field has an attribute Fixes #100461
Diffstat (limited to 'compiler/rustc_parse')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 197c0384898..ac55aee9883 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1544,8 +1544,12 @@ impl<'a> Parser<'a> { } } - if self.token.is_ident() { - // This is likely another field; emit the diagnostic and keep going + if self.token.is_ident() + || (self.token.kind == TokenKind::Pound + && (self.look_ahead(1, |t| t == &token::OpenDelim(Delimiter::Bracket)))) + { + // This is likely another field, TokenKind::Pound is used for `#[..]` attribute for next field, + // emit the diagnostic and keep going err.span_suggestion( sp, "try adding a comma", |
