Skip to content
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

Restrict parsing of bare union/struct to field types #88815

Closed
wants to merge 4 commits into from

Conversation

estebank
Copy link
Contributor

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

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.
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 10, 2021
@estebank
Copy link
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.

@rust-log-analyzer

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`.
@estebank
Copy link
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.

@estebank
Copy link
Contributor Author

Closing in favor of #88775, but the changes in this PR need to be included when relanding anon ADTs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type called union wreaks havoc since 1.54
4 participants