-
Notifications
You must be signed in to change notification settings - Fork 30
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
remove empty field list in unions #496
Conversation
Good catch! Though this is a semantic restriction, not a syntactic one (that is macros can observe the syntax still), as can be seen by the following compiling https://play.rust-lang.org/?version=stable&mode=debug&edition=2021 Could you phrase this as a legality rule? (like is done for |
Thank you for the feedback and the clarification! It seems there might have been an issue with the link you provided on the playground. Could you please resend it? Also, based on my understanding of the Rust Reference, it seems like the Union Syntax requires at least one field, in contrast to Struct and Enum. Could you please confirm if this is correct? |
Reading through the reference, it seems to actually not describe this restriction at all. The grammar lists |
Thank you for the link! I apologize in advance if I'm wrong, but I still think the Reference syntax is different from the Ferrocene one. In the reference, for unions, there is no "?" after the StructFields, while for structs and enums there is a "?", showing that fields are optional. And StructFields are defined like this: StructFields : So, I think that according to the Reference syntax, there should be at least one StructField in unions . |
Ah I see, I didn't look at the definition of |
Thank you for the explanation! I hope it is okay now. |
Sounds good, thanks! |
Build succeeded: |
Rust unions cannot have zero fields, in contrast to enums and structs. (https://github.com/ferrocene/ferrocene/blob/main/tests/ui/union/union-empty.rs)