1 // Checks that unions use type based qualification. Regression test for issue #90268.
2 #![feature(untagged_unions)]
5 union U { i: u32, c: Cell<u32> }
7 const C1: Cell<u32> = {
8 unsafe { U { c: Cell::new(0) }.c }
11 const C2: Cell<u32> = {
12 unsafe { U { i : 0 }.c }
15 const C3: Cell<u32> = {
16 let mut u = U { i: 0 };
21 const C4: U = U { i: 0 };
23 const C5: [U; 1] = [U {i : 0}; 1];
26 // Interior mutability should prevent promotion.
27 let _: &'static _ = &C1; //~ ERROR temporary value dropped while borrowed
28 let _: &'static _ = &C2; //~ ERROR temporary value dropped while borrowed
29 let _: &'static _ = &C3; //~ ERROR temporary value dropped while borrowed
30 let _: &'static _ = &C4; //~ ERROR temporary value dropped while borrowed
31 let _: &'static _ = &C5; //~ ERROR temporary value dropped while borrowed