-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse unnamed fields and anonymous structs or unions #114782
Conversation
r? @fee1-dead (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt |
r? @calebcartwright |
4fd2c91
to
f603b4f
Compare
This comment has been minimized.
This comment has been minimized.
f603b4f
to
b2acec9
Compare
This comment has been minimized.
This comment has been minimized.
b2acec9
to
28b89e0
Compare
This comment has been minimized.
This comment has been minimized.
Trying another recovery strategy. Here are the description copied from
|
2fecd54
to
689c22c
Compare
This comment has been minimized.
This comment has been minimized.
689c22c
to
10ff21b
Compare
Yes, that comment and the PR implementing it - #84571 |
Only the fact that I also wonder whether the breakage from parsing |
@frank-king
, and then think about the remaining parser changes. |
Is it that we remove all Or to simplify, we can also extract the parsing of anonymous structs or unions from |
This should be enough for now. |
186ff4d
to
f64ed0e
Compare
@frank-king |
f64ed0e
to
e7c0195
Compare
e7c0195
to
ea6c448
Compare
I'm not quite sure about which things I should move. I guess is to squash these current commits into a single one (opting out the implementation details) and move it onto a new clean PR, is it? |
…te, r=petrochenkov Parse unnamed fields and anonymous structs or unions (no-recovery) It is part of rust-lang#114782 which implements rust-lang#49804. Only parse anonymous structs or unions in struct field definition positions. r? `@petrochenkov`
☔ The latest upstream changes (presumably #115131) made this pull request unmergeable. Please resolve the merge conflicts. |
We discussed this in today's @rust-lang/lang meeting. We agreed that We discussed, briefly, whether there should be a future macro matcher that includes them (matching anonymous types or matching whole field definitions), but did not reach a consensus, and we don't think this should block on the proposal or acceptance of such a matcher. Please go ahead with |
I think that |
So I think anonymous types should belong to a new kind of |
It doesn't seem that there are any unanswered questions for lang-team to answer, so... @rustbot labels -I-lang-nominated |
Do you mean like a new kind of macro matcher? I think that can be handled in a separate PR |
No, that's beyond the goal of this PR. I was just making sure if I understood it correctly (to extend the definition of |
@frank-king any updates on this? |
Oh, I forgot to push my local commits ... I'll do a rebase and push again, and it is now worked on #115732. |
@frank-king FYI: when a PR is ready for review, send a message containing |
I'm going to close this PR, as it is already implemented by #115131 and I'm now working on #115367. This PR is only retained for discussing the recovery strategy of parsing. |
This PR is an implementation of #49804 and inherited from #99754 but uses a slightly different strategy of recovering anonymous structs or unions.
First, it tries to parse the
union { $( $field:ident: $ty:ty )* }
as an anonymous union.If successful, there can be no chance that the
union
with a record struct body is aunion
identifier with another kind of block, except for an empty body. We give up the recovery in case of theunion {}
is just a normal identifier such as inimpl union {}
.If any error occurs during the recovery, we also give up it in case of the non-empty block might be another kind of block.
The
struct
is treated similarly, except that a strict error will be emitted if thestruct
happens to be in an identifier position.