]>
Commit | Line | Data |
---|---|---|
60c5eb7d XL |
1 | A type with `packed` representation hint has a field with `align` |
2 | representation hint. | |
3 | ||
4 | Erroneous code example: | |
5 | ||
6 | ```compile_fail,E0588 | |
7 | #[repr(align(16))] | |
8 | struct Aligned(i32); | |
9 | ||
10 | #[repr(packed)] // error! | |
11 | struct Packed(Aligned); | |
12 | ``` | |
13 | ||
f25598a0 | 14 | Just like you cannot have both `align` and `packed` representation hints on the |
60c5eb7d XL |
15 | same type, a `packed` type cannot contain another type with the `align` |
16 | representation hint. However, you can do the opposite: | |
17 | ||
18 | ``` | |
19 | #[repr(packed)] | |
20 | struct Packed(i32); | |
21 | ||
22 | #[repr(align(16))] // ok! | |
23 | struct Aligned(Packed); | |
24 | ``` |