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