diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-08-30 07:18:10 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-30 07:18:10 +0200 |
| commit | 639116505a6c27a1fe4453aa6c108bc4e4976b2b (patch) | |
| tree | 9f3edc370126ce75bc07f05f5f6850a13c1b5eef /compiler/rustc_parse/src | |
| parent | dafea5f9198c9a187e9c623853cab2d4fe2e8416 (diff) | |
| parent | 3ed435f8cbb1bde962b777edebc5637353b5b7ae (diff) | |
| download | rust-639116505a6c27a1fe4453aa6c108bc4e4976b2b.tar.gz rust-639116505a6c27a1fe4453aa6c108bc4e4976b2b.zip | |
Rollup merge of #114704 - bvanjoi:fix-114636, r=compiler-errors
parser: not insert dummy field in struct Fixes #114636 This PR eliminates the dummy field, initially introduced in #113999, thereby enabling unrestricted use of `ident.unwrap()`. A side effect of this action is that we can only report the error of the first macro invocation field within the struct node. An alternative solution might be giving a virtual name to the macro, but it appears more complex.(https://github.com/rust-lang/rust/issues/114636#issuecomment-1670228715). Furthermore, if you think https://github.com/rust-lang/rust/issues/114636#issuecomment-1670228715 is a better solution, feel free to close this PR.
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 5db31c23478..233c7016417 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1851,21 +1851,11 @@ impl<'a> Parser<'a> { attrs: AttrVec, ) -> PResult<'a, FieldDef> { let name = self.parse_field_ident(adt_ty, lo)?; - // Parse the macro invocation and recover if self.token.kind == token::Not { if let Err(mut err) = self.unexpected::<FieldDef>() { - err.subdiagnostic(MacroExpandsToAdtField { adt_ty }).emit(); - self.bump(); - self.parse_delim_args()?; - return Ok(FieldDef { - span: DUMMY_SP, - ident: None, - vis, - id: DUMMY_NODE_ID, - ty: self.mk_ty(DUMMY_SP, TyKind::Err), - attrs, - is_placeholder: false, - }); + // Encounter the macro invocation + err.subdiagnostic(MacroExpandsToAdtField { adt_ty }); + return Err(err); } } self.expect_field_ty_separator()?; |
