summaryrefslogtreecommitdiffstats
path: root/tests/ui/union/union-lint-dead-code.rs
blob: 65aaf0a1d35dac7c34710c6f5ca1763c08951640 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// revisions: mirunsafeck thirunsafeck
// [thirunsafeck]compile-flags: -Z thir-unsafeck

#![deny(dead_code)]

union Foo {
    x: usize,
    b: bool, //~ ERROR: field `b` is never read
    _unused: u16,
}

fn field_read(f: Foo) -> usize {
    unsafe { f.x }
}

fn main() {
    let _ = field_read(Foo { x: 2 });
}