-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Allow the last field of a struct to be a DST #13121
Comments
This will interact with inherited fields for virtual structs. I propose we order the fields in structs with the base struct first and the concrete struct last. Then we only allow a DST field in non-virtual structs, which means they would actually be the last field. |
Now with proper checking of enums and allows unsized fields as the last field in a struct or variant. This PR only checks passing of unsized types and distinguishing them from sized ones. To be safe we also need to control storage. Closes issues #12969 and #13121, supersedes #13375 (all the discussion there is valid here too).
@nick29581 Is this done with 696f16e merged? |
Something that came up in an IRC discussion (which botbot.me unfortunately failed to capture completely): when the last field of a struct is unsized, is it always supposed to be one of the type parameters to the struct, as is shown in the examples on niko's blog? Or is one allowed to have an unsized field where the struct could never be instantiated to a sized version of itself? I.e. compare these two variants: struct Foo<Sized? T> { x: int, d: T }
struct Bar{ x: int, d: [int] } I assume the way one would create an instance of the latter, if it is allowed at all, would be via (update: deleted bogus example that tried to have unsized local variables. And it also tried to transmute a Or perhaps it would be legal to do |
@pnkfelix I believe both are allowed but the only way to create the |
Fixed |
…nerics, r=Veykril Support const generics for builtin derive macro Fixes rust-lang#13121 We have been treating every generic parameter as type parameter during builtin derive macro expansion. This patch adds support for const generics in such expansions.
blocks #12938
assigned to me
The text was updated successfully, but these errors were encountered: