Skip to content

Commit 6f6f3e8

Browse files
authored
Rollup merge of #65591 - GuillaumeGomez:long-err-explanation-E0588, r=Dylan-DPC
Add long error explanation for E0588 Part of #61137. r? @kinnison
2 parents 1dbb010 + 07f2f05 commit 6f6f3e8

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

src/librustc_typeck/error_codes.rs

+32-6
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ a guard.
194194
```compile_fail,E0029
195195
let string = "salutations !";
196196
197-
// The ordering relation for strings can't be evaluated at compile time,
197+
// The ordering relation for strings cannot be evaluated at compile time,
198198
// so this doesn't work:
199199
match string {
200200
"hello" ..= "world" => {}
@@ -348,7 +348,7 @@ fn main() {
348348
"##,
349349

350350
E0044: r##"
351-
You can't use type or const parameters on foreign items.
351+
You cannot use type or const parameters on foreign items.
352352
Example of erroneous code:
353353
354354
```compile_fail,E0044
@@ -788,7 +788,7 @@ fn some_other_func() {}
788788
fn some_function() {
789789
SOME_CONST = 14; // error : a constant value cannot be changed!
790790
1 = 3; // error : 1 isn't a valid place!
791-
some_other_func() = 4; // error : we can't assign value to a function!
791+
some_other_func() = 4; // error : we cannot assign value to a function!
792792
SomeStruct.x = 12; // error : SomeStruct a structure name but it is used
793793
// like a variable!
794794
}
@@ -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 cannot have both `align` and `packed` representation hints on a
3909+
same type, a `packed` type cannot 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.
@@ -4299,7 +4326,7 @@ extern {
42994326
43004327
unsafe {
43014328
printf(::std::ptr::null(), 0f32);
4302-
// error: can't pass an `f32` to variadic function, cast to `c_double`
4329+
// error: cannot pass an `f32` to variadic function, cast to `c_double`
43034330
}
43044331
```
43054332
@@ -5000,7 +5027,7 @@ the future, [RFC 2091] prohibits their implementation without a follow-up RFC.
50005027
// E0174,
50015028
// E0182, // merged into E0229
50025029
E0183,
5003-
// E0187, // can't infer the kind of the closure
5030+
// E0187, // cannot infer the kind of the closure
50045031
// E0188, // can not cast an immutable reference to a mutable pointer
50055032
// E0189, // deprecated: can only cast a boxed pointer to a boxed object
50065033
// E0190, // deprecated: can only cast a &-pointer to an &-object
@@ -5047,7 +5074,6 @@ the future, [RFC 2091] prohibits their implementation without a follow-up RFC.
50475074
// E0564, // only named lifetimes are allowed in `impl Trait`,
50485075
// but `{}` was found in the type `{}`
50495076
E0587, // type has conflicting packed and align representation hints
5050-
E0588, // packed type cannot transitively contain a `[repr(align)]` type
50515077
// E0611, // merged into E0616
50525078
// E0612, // merged into E0609
50535079
// E0613, // Removed (merged with E0609)

src/test/ui/repr/repr-packed-contains-align.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ LL | | }
5656

5757
error: aborting due to 8 previous errors
5858

59+
For more information about this error, try `rustc --explain E0588`.

0 commit comments

Comments
 (0)