rust/compiler/rustc_const_eval
bors 9ed5b94b28 Auto merge of #90373 - tmiasko:union-qualification, r=oli-obk
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.

Fixes #90268.

`@rust-lang/wg-const-eval`
2021-10-29 12:21:09 +00:00
..
src Auto merge of #90373 - tmiasko:union-qualification, r=oli-obk 2021-10-29 12:21:09 +00:00
Cargo.toml Remove unused dependencies from rustc_const_eval 2021-10-14 15:42:42 -05:00