2 #![allow(unused_assignments)]
4 // Drop works for union itself.
6 use std::mem::ManuallyDrop;
16 unsafe { CHECK += 10; }
22 unsafe { CHECK += 1; }
26 static mut CHECK: u8 = 0;
30 let mut u = U { a: ManuallyDrop::new(S) };
32 u = U { a: ManuallyDrop::new(S) };
33 assert_eq!(CHECK, 1); // union itself is assigned, union is dropped, field is not dropped
35 assert_eq!(CHECK, 11); // union field is assigned, field is dropped