-
Notifications
You must be signed in to change notification settings - Fork 13.3k
E0277 for unions only mentions structs and enum variants #36312
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
Comments
Similar to #36252. |
Is there any reason to forbid any (and arbitrary number of) union variant from being dynamically sized? As far as layout is concerned every single field/variant of union is the last. |
@nagisa I'd like to see dynamically sized union fields supported as well. |
What is the motivation? (Besides "Why not?") |
@petrochenkov My original use case was something like: union Inner<T: ?Sized> {
value: T,
}
pub struct NoDrop<T: ?Sized>(Inner<T>); where you want something like |
@petrochenkov Is there any non-trivial design question that arises from putting DSTs in a union, or would they just work in the obvious way? Not arguing against an additional RFC here, just asking if I've missed some unexpected complexity arising from that combination. |
@joshtriplett |
Aside from the overall question of DSTs in unions, for the time being we should fix the error message here in some way, but I don't know if we have access to whether it's a union or struct at that point -- "last field" for a union doesn't really make sense. |
…nkov udpdate error message for unsized union field Fixes #36312.
The note issued for the following is "only the last field of a struct or enum variant may have a dynamically sized type," which is confusing, since no struct or enum variant is used:
The text was updated successfully, but these errors were encountered: