]> git.lizzy.rs Git - rust.git/blob - src/test/ui/union/union-lint-dead-code.rs
Rollup merge of #100462 - zohnannor:master, r=thomcc
[rust.git] / src / test / ui / union / union-lint-dead-code.rs
1 // revisions: mirunsafeck thirunsafeck
2 // [thirunsafeck]compile-flags: -Z thir-unsafeck
3
4 #![deny(dead_code)]
5
6 union Foo {
7     x: usize,
8     b: bool, //~ ERROR: field `b` is never read
9     _unused: u16,
10 }
11
12 fn field_read(f: Foo) -> usize {
13     unsafe { f.x }
14 }
15
16 fn main() {
17     let _ = field_read(Foo { x: 2 });
18 }