Closed
Description
For example, after laundering interior mutability through a union, a resulting constant undergoes promotion:
#![feature(untagged_unions)]
use std::cell::Cell;
pub const CELL: Option<Cell<u32>> = {
union U { i: u32, c: Cell<u32> }
Some(unsafe { U { i: 0 }.c })
};
fn main() {
let _ = &CELL;
}
error[E0080]: it is undefined behavior to use this value
--> u.rs:9:1
|
9 | fn main() {
| ^^^^^^^^^ type validation failed at .<deref>.<enum-variant(Some)>.0.value: encountered `UnsafeCell` in a `const`
...
@rustbot label +A-const-eval +F-untagged_unions