]>
Commit | Line | Data |
---|---|---|
ed00b5ec | 1 | // skip-filecheck |
49aad941 | 2 | // unit-test: ConstProp |
fe692bf9 | 3 | // EMIT_MIR_FOR_EACH_PANIC_STRATEGY |
49aad941 | 4 | |
ed00b5ec | 5 | #![feature(offset_of, offset_of_enum)] |
49aad941 FG |
6 | |
7 | use std::marker::PhantomData; | |
8 | use std::mem::offset_of; | |
9 | ||
10 | struct Alpha { | |
11 | x: u8, | |
12 | y: u16, | |
13 | z: Beta, | |
14 | } | |
15 | ||
16 | struct Beta(u8, u8); | |
17 | ||
18 | struct Gamma<T> { | |
19 | x: u8, | |
20 | y: u16, | |
21 | _t: T, | |
22 | } | |
23 | ||
24 | #[repr(C)] | |
25 | struct Delta<T> { | |
26 | _phantom: PhantomData<T>, | |
27 | x: u8, | |
28 | y: u16, | |
29 | } | |
30 | ||
ed00b5ec FG |
31 | enum Epsilon { |
32 | A(u8, u16), | |
33 | B, | |
34 | C { c: u32 } | |
35 | } | |
36 | ||
37 | enum Zeta<T> { | |
38 | A(T, bool), | |
39 | B(char), | |
40 | } | |
41 | ||
49aad941 FG |
42 | // EMIT_MIR offset_of.concrete.ConstProp.diff |
43 | fn concrete() { | |
44 | let x = offset_of!(Alpha, x); | |
45 | let y = offset_of!(Alpha, y); | |
46 | let z0 = offset_of!(Alpha, z.0); | |
47 | let z1 = offset_of!(Alpha, z.1); | |
ed00b5ec FG |
48 | let eA0 = offset_of!(Epsilon, A.0); |
49 | let eA1 = offset_of!(Epsilon, A.1); | |
50 | let eC = offset_of!(Epsilon, C.c); | |
49aad941 FG |
51 | } |
52 | ||
53 | // EMIT_MIR offset_of.generic.ConstProp.diff | |
54 | fn generic<T>() { | |
55 | let gx = offset_of!(Gamma<T>, x); | |
56 | let gy = offset_of!(Gamma<T>, y); | |
57 | let dx = offset_of!(Delta<T>, x); | |
58 | let dy = offset_of!(Delta<T>, y); | |
ed00b5ec FG |
59 | let zA0 = offset_of!(Zeta<T>, A.0); |
60 | let zA1 = offset_of!(Zeta<T>, A.1); | |
61 | let zB = offset_of!(Zeta<T>, B.0); | |
49aad941 FG |
62 | } |
63 | ||
64 | fn main() { | |
65 | concrete(); | |
66 | generic::<()>(); | |
67 | } |