]> git.lizzy.rs Git - rust.git/blob - src/test/ui/union/union-fields-1.rs
Rollup merge of #75882 - pickfire:patch-6, r=jyn514
[rust.git] / src / test / ui / union / union-fields-1.rs
1 #![deny(dead_code)]
2
3 union U1 {
4     a: u8, // should not be reported
5     b: u8, // should not be reported
6     c: u8, //~ ERROR field is never read
7 }
8 union U2 {
9     a: u8, //~ ERROR field is never read
10     b: u8, // should not be reported
11     c: u8, // should not be reported
12 }
13 union NoDropLike { a: u8 } //~ ERROR field is never read
14
15 union U {
16     a: u8, // should not be reported
17     b: u8, // should not be reported
18     c: u8, //~ ERROR field is never read
19 }
20 type A = U;
21
22 fn main() {
23     let u = U1 { a: 0 };
24     let _a = unsafe { u.b };
25
26     let u = U2 { c: 0 };
27     let _b = unsafe { u.b };
28
29     let _u = NoDropLike { a: 10 };
30     let u = A { a: 0 };
31     let _b = unsafe { u.b };
32 }