Closed
Description
(This has already been reported in #32836 (comment) but not as a proper issue, and I still encountered this today, so filed a separated issue here to ensure it is still visible.)
Test case:
union U {
x: u32,
y: f32,
}
fn main() {
let u = U { x: 0x3f800000 };
let _f = unsafe { u.y };
}
This produces an unused field warning, which is incorrect:
warning: field is never used: `x`
--> src/main.rs:2:5
|
2 | x: u32,
| ^^^^^^
|
= note: #[warn(dead_code)] on by default
The initialization of field x
should also be considered a use.
Repro on playground, all of stable (1.19.0), beta (1.20.0-beta.1) and nightly (1.20.0-nightly ae98ebf 2017-07-20).