1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
//@ run-pass
//@ compile-flags: -C debug-assertions
#[allow(dead_code)]
#[repr(u16)]
enum Mix {
A,
B(u16),
}
#[allow(dead_code)]
enum Nested {
C(Mix),
D,
E,
}
#[allow(dead_code)]
struct Bar {
a: u16,
b: u16,
}
fn main() {
let _val: Nested = unsafe { std::mem::transmute::<_, Nested>(Bar { a: 0, b: 0 }) };
let _val: Nested = unsafe { std::mem::transmute::<_, Nested>(Bar { a: 1, b: 0 }) };
let _val: Nested = unsafe { std::mem::transmute::<_, Nested>(Bar { a: 2, b: 0 }) };
let _val: Nested = unsafe { std::mem::transmute::<_, Nested>(Bar { a: 3, b: 0 }) };
}
|