2021-05-13 14:42:25 +00:00
|
|
|
// revisions: mirunsafeck thirunsafeck
|
|
|
|
// [thirunsafeck]compile-flags: -Z thir-unsafeck
|
|
|
|
|
2017-07-21 23:17:53 +00:00
|
|
|
#![deny(dead_code)]
|
|
|
|
|
2017-08-06 15:19:15 +00:00
|
|
|
union U1 {
|
|
|
|
a: u8, // should not be reported
|
|
|
|
b: u8, // should not be reported
|
2022-06-10 03:14:24 +00:00
|
|
|
c: u8, //~ ERROR field `c` is never read
|
2017-07-21 23:17:53 +00:00
|
|
|
}
|
2017-08-06 15:19:15 +00:00
|
|
|
union U2 {
|
2022-06-10 03:14:24 +00:00
|
|
|
a: u8, //~ ERROR field `a` is never read
|
2017-08-06 15:19:15 +00:00
|
|
|
b: u8, // should not be reported
|
|
|
|
c: u8, // should not be reported
|
2017-07-21 23:17:53 +00:00
|
|
|
}
|
2022-06-10 03:14:24 +00:00
|
|
|
union NoDropLike { a: u8 } //~ ERROR field `a` is never read
|
2017-07-21 23:17:53 +00:00
|
|
|
|
2017-08-06 18:46:32 +00:00
|
|
|
union U {
|
|
|
|
a: u8, // should not be reported
|
|
|
|
b: u8, // should not be reported
|
2022-06-10 03:14:24 +00:00
|
|
|
c: u8, //~ ERROR field `c` is never read
|
2017-08-06 18:46:32 +00:00
|
|
|
}
|
|
|
|
type A = U;
|
|
|
|
|
2017-07-21 23:17:53 +00:00
|
|
|
fn main() {
|
2017-08-06 15:19:15 +00:00
|
|
|
let u = U1 { a: 0 };
|
|
|
|
let _a = unsafe { u.b };
|
2017-07-21 23:17:53 +00:00
|
|
|
|
2017-08-06 15:19:15 +00:00
|
|
|
let u = U2 { c: 0 };
|
|
|
|
let _b = unsafe { u.b };
|
|
|
|
|
|
|
|
let _u = NoDropLike { a: 10 };
|
2017-08-06 18:46:32 +00:00
|
|
|
let u = A { a: 0 };
|
|
|
|
let _b = unsafe { u.b };
|
2017-08-06 15:19:15 +00:00
|
|
|
}
|