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.
This commit is contained in:
commit
639116505a
3 changed files with 48 additions and 52 deletions
|
@ -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()?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue