Skip to content

Commit 429f91c

Browse files
Add long error explanation for E0588
1 parent 14f0ed6 commit 429f91c

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/librustc_typeck/error_codes.rs

+27-1
Original file line numberDiff line numberDiff line change
@@ -3891,6 +3891,33 @@ details.
38913891
[issue #33685]: https://github.com/rust-lang/rust/issues/33685
38923892
"##,
38933893

3894+
E0588: r##"
3895+
A type with `packed` representation hint has a field with `align`
3896+
representation hint.
3897+
3898+
Erroneous code example:
3899+
3900+
```compile_fail,E0588
3901+
#[repr(align(16))]
3902+
struct Aligned(i32);
3903+
3904+
#[repr(packed)] // error!
3905+
struct Packed(Aligned);
3906+
```
3907+
3908+
Just like you can't have both `align` and `packed` representation hints on a
3909+
same type, a `packed` type can't contain another type with the `align`
3910+
representation hint. However, you can do the opposite:
3911+
3912+
```
3913+
#[repr(packed)]
3914+
struct Packed(i32);
3915+
3916+
#[repr(align(16))] // ok!
3917+
struct Aligned(Packed);
3918+
```
3919+
"##,
3920+
38943921
E0592: r##"
38953922
This error occurs when you defined methods or associated functions with same
38963923
name.
@@ -5043,7 +5070,6 @@ the future, [RFC 2091] prohibits their implementation without a follow-up RFC.
50435070
// E0564, // only named lifetimes are allowed in `impl Trait`,
50445071
// but `{}` was found in the type `{}`
50455072
E0587, // type has conflicting packed and align representation hints
5046-
E0588, // packed type cannot transitively contain a `[repr(align)]` type
50475073
// E0611, // merged into E0616
50485074
// E0612, // merged into E0609
50495075
// E0613, // Removed (merged with E0609)

0 commit comments

Comments
 (0)