Restrict parsing of bare union/struct to field types#88815
Closed
estebank wants to merge 4 commits intorust-lang:masterfrom
Closed
Restrict parsing of bare union/struct to field types#88815estebank wants to merge 4 commits intorust-lang:masterfrom
estebank wants to merge 4 commits intorust-lang:masterfrom
Conversation
Do not unconditionally parse bare types everywhere, only parse them if they are in a field type, and try them when recovering a misparse everywhere else, using them only if they are successfuly fully parsed. Fix rust-lang#88583.
This was referenced Sep 10, 2021
Contributor
Author
|
This PR can be simplified if we do not care to have good diagnostics in all incorrect places where an anonymous ADT might end up in. |
This comment has been minimized.
This comment has been minimized.
`type X = union {}` isn't supported. Trying to pretty print it will emit a
`delay_as_bug` error to be emitted because a later stage should have
triggered under normal circumstances.
It didn't need to be that complex, the `look_ahead` check was enough, as braces aren't allowed after neither `static` or `type`.
Contributor
Author
|
@petrochenkov could you provide some feedback on what you find objectionable in this PR? The parser recovery included is to keep the same level of diagnostics. Most of it can be safely removed with no loss of functionality, just confusion when trying to use bare ADTs anywhere else than type fields. |
Contributor
Author
|
Closing in favor of #88775, but the changes in this PR need to be included when relanding anon ADTs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Do not unconditionally parse bare types everywhere, only parse them if
they are in a field type, and try them when recovering a misparse
everywhere else, using them only if they are successfuly fully parsed.
Fix #88583.
r? @pnkfelix