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