diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-10-28 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-10-28 00:00:00 +0000 |
| commit | 3f778f31b6b285d41973a36ee1f4a2291d5f6a03 (patch) | |
| tree | 481c04442df1d480a326568039853a1fb7f5c019 /compiler/rustc_mir_transform/src/coverage/debug.rs | |
| parent | 4e0d3973fafdfb1c51011bc74e44257b5e3863f1 (diff) | |
| download | rust-3f778f31b6b285d41973a36ee1f4a2291d5f6a03.tar.gz rust-3f778f31b6b285d41973a36ee1f4a2291d5f6a03.zip | |
Use type based qualification for unions
Union field access is currently qualified based on the qualification of
a value previously assigned to the union. At the same time, every union
access transmutes the content of the union, which might result in a
different qualification.
For example, consider constants A and B as defined below, under the
current rules neither contains interior mutability, since a value used
in the initial assignment did not contain `UnsafeCell` constructor.
```rust
#![feature(untagged_unions)]
union U { i: u32, c: std::cell::Cell<u32> }
const A: U = U { i: 0 };
const B: std::cell::Cell<u32> = unsafe { U { i: 0 }.c };
```
To avoid the issue, the changes here propose to consider the content of
a union as opaque and use type based qualification for union types.
Diffstat (limited to 'compiler/rustc_mir_transform/src/coverage/debug.rs')
0 files changed, 0 insertions, 0 deletions
