about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorbohan <bohan-zhang@foxmail.com>2023-08-21 21:05:01 +0800
committerbohan <bohan-zhang@foxmail.com>2023-08-21 21:05:01 +0800
commit3ed435f8cbb1bde962b777edebc5637353b5b7ae (patch)
tree9b639f78965db15f9b2d0930999e298fe6175342 /compiler/rustc_parse/src/parser
parent5e9d3d8a03fadf1877286528e5c9d0c056ac82b5 (diff)
downloadrust-3ed435f8cbb1bde962b777edebc5637353b5b7ae.tar.gz
rust-3ed435f8cbb1bde962b777edebc5637353b5b7ae.zip
discard dummy field for macro invocation when parse struct
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/item.rs16
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 24c65d061f9..b76cf9bf8c2 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()?;