Uh oh!
There was an error while loading. Please reload this page.
Make assignments to Copy union fields safe - #42083
Conversation
| let field_ty = self.tables.expr_ty_adjusted(lhs); | ||
| let owner_def_id = self.tcx.hir.body_owner_def_id(self.body_id); | ||
| let param_env = self.tcx.parameter_environment(owner_def_id); | ||
| if field_ty.moves_by_default(self.tcx, ¶m_env, field.span) { |
There was a problem hiding this comment.
Is there a way to query "current parameter environment" or "current body id" without keeping them in the visitor, like I did here?
There was a problem hiding this comment.
(I think what I would rather do is to have a loop over all the bodies and instantiate a distinct visitor per body, with just the appropriate tables etc. This visitor would have to walk up to find out contextual information though (since closures, at least, inherit their "unsafety" from their parents at present.))
alexcrichton
commented
May 18, 2017
I think @nikomatsakis is out today, but we'll make sure he gets around to this in the near future! |
carols10cents
commented
May 22, 2017
ping @nikomatsakis, are you back from PTO? have some more reviews! |
nikomatsakis
commented
May 23, 2017
@bors r+ |
bors
commented
May 23, 2017
📌 Commit 59b65b3 has been approved by |
…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
Mark-Simulacrum
commented
May 24, 2017
I suspect that this will fail at some point, the previous rollup failed with, which looks suspiciously like it comes from this PR; possibly a conflict with another PR that landed -- I seem to recall @nikomatsakis landing something that renamed |
petrochenkov
commented
May 25, 2017
@bors r- |
Rebased. |
bors
commented
May 25, 2017
📌 Commit fa13cd3 has been approved by |
bors
commented
May 25, 2017
💡 This pull request was already approved, no need to approve it again.
|
bors
commented
May 25, 2017
📌 Commit fa13cd3 has been approved by |
bors
commented
May 26, 2017
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
bors
commented
May 26, 2017
☀️ Test successful - status-appveyor, status-travis |
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
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
Copyunion fields do not read any data from the union and are equivalent 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_unsafelint in stable code.cc #32836
r? @nikomatsakis