-
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
Stabilize unions with Copy
fields and no destructor
#42068
Conversation
Glad to see this becoming stable!
I am not generally a fan of backporting anything that's not crucial. |
ping @nikomatsakis, pinging you on IRC too! |
I'm waiting on this until #42083 lands. |
…akis Make assignments to `Copy` union fields safe This is an accompanying PR to PR rust-lang#42068 stabilizing FFI unions. This was first proposed in rust-lang#32836 (comment), see subsequent comments as well. Assignments to `Copy` union fields do not read any data from the union and are [equivalent](rust-lang#32836 (comment)) to whole union assignments, which are safe, so they should be safe as well. This removes a significant number of "false positive" unsafe blocks, in code dealing with FFI unions in particular. It desirable to make this change now, together with stabilization of FFI unions, because now it affecfts only unstable code, but later it will cause warnings/errors caused by `unused_unsafe` lint in stable code. cc rust-lang#32836 r? @nikomatsakis
…akis Make assignments to `Copy` union fields safe This is an accompanying PR to PR rust-lang#42068 stabilizing FFI unions. This was first proposed in rust-lang#32836 (comment), see subsequent comments as well. Assignments to `Copy` union fields do not read any data from the union and are [equivalent](rust-lang#32836 (comment)) to whole union assignments, which are safe, so they should be safe as well. This removes a significant number of "false positive" unsafe blocks, in code dealing with FFI unions in particular. It desirable to make this change now, together with stabilization of FFI unions, because now it affecfts only unstable code, but later it will cause warnings/errors caused by `unused_unsafe` lint in stable code. cc rust-lang#32836 r? @nikomatsakis
Make assignments to `Copy` union fields safe This is an accompanying PR to PR #42068 stabilizing FFI unions. This was first proposed in #32836 (comment), see subsequent comments as well. Assignments to `Copy` union fields do not read any data from the union and are [equivalent](#32836 (comment)) to whole union assignments, which are safe, so they should be safe as well. This removes a significant number of "false positive" unsafe blocks, in code dealing with FFI unions in particular. It desirable to make this change now, together with stabilization of FFI unions, because now it affecfts only unstable code, but later it will cause warnings/errors caused by `unused_unsafe` lint in stable code. cc #32836 r? @nikomatsakis
☔ The latest upstream changes (presumably #42083) made this pull request unmergeable. Please resolve the merge conflicts. |
r=me once rebased |
@bors r=nikomatsakis |
📌 Commit 73c73e4 has been approved by |
⌛ Testing commit 73c73e4 with merge fc26e66... |
💔 Test failed - status-appveyor |
@bors retry
|
Stabilize unions with `Copy` fields and no destructor What else is needed: - [x] Documentation (rust-lang/reference#57). - [x] Making assignments to `Copy` union fields safe (#42083). - [ ] Backport? (The "stabilization decision" is from [Apr 13](#32836 (comment)), it's just this PR is late.) cc #32836 r? @nikomatsakis
☀️ Test successful - status-appveyor, status-travis |
Were going to try to backport. |
cc @rust-lang/compiler |
@brson I don't strongly object, but I'm surprised you would backport. I feel like we try to keep backports to regressions or important bug fixes, and only rarely backport stabilizations -- the exception would be if some feature is hotly demanded. But otoh this seems pretty darn low risk, so no real objection. |
I closed the backport. It was feeling non-trivial and there wasn't a great deal of agreement about it. |
What else is needed:
Copy
union fields safe (Make assignments toCopy
union fields safe #42083).cc #32836
r? @nikomatsakis