rust/tests/ui/union/union-lint-dead-code.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
312 B
Rust
Raw Normal View History

// revisions: mirunsafeck thirunsafeck
// [thirunsafeck]compile-flags: -Z thir-unsafeck
2016-09-05 12:19:00 -05:00
#![deny(dead_code)]
union Foo {
x: usize,
b: bool, //~ ERROR: field `b` is never read
2016-09-05 12:19:00 -05:00
_unused: u16,
}
fn field_read(f: Foo) -> usize {
unsafe { f.x }
}
fn main() {
let _ = field_read(Foo { x: 2 });
}