]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0588.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0588.md
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
14 Just like you cannot have both `align` and `packed` representation hints on a
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 ```