2 // revisions: mirunsafeck thirunsafeck
3 // [thirunsafeck]compile-flags: -Z thir-unsafeck
5 type Field1 = (i32, u32);
15 const FLOAT1_AS_I32: i32 = 1065353216;
16 const UNION: DummyUnion = DummyUnion { field1: (FLOAT1_AS_I32, 0) };
18 const fn read_field1() -> Field1 {
19 const FIELD1: Field1 = unsafe { UNION.field1 };
23 const fn read_field2() -> Field2 {
24 const FIELD2: Field2 = unsafe { UNION.field2 };
28 const fn read_field3() -> Field3 {
29 const FIELD3: Field3 = unsafe { UNION.field3 };
34 let foo = FLOAT1_AS_I32;
35 assert_eq!(read_field1().0, foo);
36 assert_eq!(read_field1().0, FLOAT1_AS_I32);
39 assert_eq!(read_field2(), foo);
40 assert_eq!(read_field2(), 1.0);
42 assert_eq!(read_field3(), unsafe { UNION.field3 });
43 let foo = unsafe { UNION.field3 };
44 assert_eq!(read_field3(), foo);