-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
#[cfg]
on struct field permits empty unusable struct
#16819
Comments
Triage: still an issue. Sub-bug of #24266. |
Note, that after #28336 empty tuple structs are still disallowed, but obtainable with
IMO, amending rust-lang/rfcs#218 to allow empty tuple structs would be the best solution. |
(note that rust-lang/rfcs#218 did include discussion of the generalization to empty tuple structs... in short, I do not think you can directly generalize the RFC's strategy to tuple structs, though there may be some more limited generalization available.) (I personally think the better approach here would be to explicitly disallow using |
This patch uses the same data structures for structs and enum variants in AST and HIR. These changes in data structures lead to noticeable simplification in most of code dealing with them. I didn't touch the top level, i.e. `ItemStruct` is still `ItemStruct` and not `ItemEnum` with one variant, like in the type checker. As part of this patch, structures and variants get the `kind` field making distinction between "normal" structs, tuple structs and unit structs explicit instead of relying on the number of fields and presence of constructor `NodeId`. In particular, we can now distinguish empty tuple structs from unit structs, which was impossible before! Comprehensive tests for empty structs are added and some improvements to empty struct feature gates are made. Some tests don't pass due to issue #28692 , they are still there for completeness, but are commented out. This patch fixes issue mentioned in #16819 (comment), now emptiness of tuple structs is checked after expansion. It also touches #28750 by providing span for visit_struct_def cc #28336 r? @nrc
internal: Improve rooted upmapping cc rust-lang/rust-analyzer#16235
Here
S { }
is suggested but it is also not allowed:The text was updated successfully, but these errors were encountered: