1 // Checks that unions use type based qualification. Regression test for issue #90268.
4 use std::mem::ManuallyDrop;
6 union U { i: u32, c: ManuallyDrop<Cell<u32>> }
8 const C1: ManuallyDrop<Cell<u32>> = {
9 unsafe { U { c: ManuallyDrop::new(Cell::new(0)) }.c }
12 const C2: ManuallyDrop<Cell<u32>> = {
13 unsafe { U { i : 0 }.c }
16 const C3: ManuallyDrop<Cell<u32>> = {
17 let mut u = U { i: 0 };
22 const C4: U = U { i: 0 };
24 const C5: [U; 1] = [U {i : 0}; 1];
27 // Interior mutability should prevent promotion.
28 let _: &'static _ = &C1; //~ ERROR temporary value dropped while borrowed
29 let _: &'static _ = &C2; //~ ERROR temporary value dropped while borrowed
30 let _: &'static _ = &C3; //~ ERROR temporary value dropped while borrowed
31 let _: &'static _ = &C4; //~ ERROR temporary value dropped while borrowed
32 let _: &'static _ = &C5; //~ ERROR temporary value dropped while borrowed