-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #94305 - JakobDegen:dp-1, r=oli-obk
Remove an unnecessary restriction in `dest_prop` I had asked about this [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Do.20unions.20have.20active.20fields.3F) but didn't receive a response, so putting up this PR that makes the change I think we can. If it turns out that this is wrong, hopefully I'll find out here. Reposting my Zulip comment: > Not sure what channel to put this into, so using this as a fallback. The dest prop MIR opt has this comment: > > ```rust > //! Subtle case: If `dest` is a, or projects through a union, then we have to make sure that there > //! remains an assignment to it, since that sets the "active field" of the union. But if `src` is > //! a ZST, it might not be initialized, so there might not be any use of it before the assignment, > //! and performing the optimization would simply delete the assignment, leaving `dest` > //! uninitialized. > ``` > > In particular, the claim seems to be that we can't take > ``` > x = (); > y.field = x; > ``` > where `y` is a union having `field: ()` as one of its variants, and optimize the entire thing away (assuming `x` is unused otherwise). As far as I know though, Rust unions don't have active fields. Is this comment correct and am I missing something? Is there a worry about this interacting poorly with FFI code/C unions/LTO or something? This PR just removes that comment and the associated code. Also it fixes one unrelated comment that did not match the code it was commenting on. r? rust-lang/mir-opt
- Loading branch information
Showing
3 changed files
with
20 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters