]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/union-ice.rs
Rollup merge of #89891 - ojeda:modular-alloc, r=Mark-Simulacrum
[rust.git] / src / test / ui / consts / const-eval / union-ice.rs
1 // only-x86_64
2
3 type Field1 = i32;
4 type Field3 = i64;
5
6 #[repr(C)]
7 union DummyUnion {
8     field1: Field1,
9     field3: Field3,
10 }
11
12 const UNION: DummyUnion = DummyUnion { field1: 1065353216 };
13
14 const FIELD3: Field3 = unsafe { UNION.field3 };
15 //~^ ERROR evaluation of constant value failed
16 //~| uninitialized
17
18 const FIELD_PATH: Struct = Struct {
19     a: 42,
20     b: unsafe { UNION.field3 },
21     //~^ ERROR evaluation of constant value failed
22     //~| uninitialized
23 };
24
25 struct Struct {
26     a: u8,
27     b: Field3,
28 }
29
30 const FIELD_PATH2: Struct2 = Struct2 {
31     b: [
32         21,
33         unsafe { UNION.field3 },
34         //~^ ERROR evaluation of constant value failed
35         //~| uninitialized
36         23,
37         24,
38     ],
39     a: 42,
40 };
41
42 struct Struct2 {
43     b: [Field3; 4],
44     a: u8,
45 }
46
47 fn main() {
48 }