f9f97b661a
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 |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |