-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Under what conditions can you implement Copy for a union? #65748
Comments
+1 |
I still think the same way.
|
The current behavior does fortunately seem to enforce the "all variants" behavior: #![feature(untagged_unions)]
struct NoCopy;
#[derive(Clone, Copy)]
struct IsCopy;
#[derive(Clone, Copy)]
union U {
a: NoCopy,
b: IsCopy,
} results in an error: error[E0204]: the trait `Copy` may not be implemented for this type
--> src/lib.rs:8:17
|
8 | #[derive(Clone, Copy)]
| ^^^^
9 | union U {
10 | a: NoCopy,
| --------- this field does not implement `Copy` I agree that it is a sensible conservative default. |
There don't seem to be any sensible alternatives to the current behaviour. What else could the condition possibly be? |
@rfcbot fcp merge We discussed this in today's @rust-lang/lang meeting and we all felt that this behavior seemed like the obvious and correct one. It is also the one that is presently implemented. Moreover, it's a conservative choice -- if we wanted to permit |
Team member @nikomatsakis has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
The current behavior is not accidental and it has a test ( |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. The RFC will be merged soon. |
Moving all remaining work to the reference in rust-lang/reference#709 now that FCP is complete. |
From #32836 (comment):
@RalfJung notes in #55149 (comment) that:
cc #55149
The text was updated successfully, but these errors were encountered: