2021-05-13 09:42:25 -05:00
|
|
|
// revisions: mirunsafeck thirunsafeck
|
|
|
|
// [thirunsafeck]compile-flags: -Z thir-unsafeck
|
|
|
|
|
2016-09-05 12:19:00 -05:00
|
|
|
#![deny(dead_code)]
|
|
|
|
|
|
|
|
union Foo {
|
|
|
|
x: usize,
|
2022-06-09 22:14:24 -05:00
|
|
|
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 });
|
|
|
|
}
|