Closed
Description
Given the following code:
#[repr(transparent)]
pub struct Aligned<T, A> {
align: [A; 0],
value: T,
}
The current output is:
error[E0690]: transparent struct needs at most one non-zero-sized field, but has 2
--> kernel/src/align.rs:2:1
|
2 | pub struct Aligned<T, A> {
| ^^^^^^^^^^^^^^^^^^^^^^^^ needs at most one non-zero-sized field, but has 2
3 | align: [A; 0],
| ------------- this field is non-zero-sized
4 | value: T,
| -------- this field is non-zero-sized
For more information about this error, try `rustc --explain E0690`.
Ideally the output should look like:
error[E0691]: zero-sized field in transparent struct has alignment larger than 1
--> kernel/src/align.rs:3:5
|
3 | align: [A; 0],
| ^^^^^^^^^^^^^ may have alignment larger than 1
|
help: consider changing `#[repr(transparent)]` to `#[repr(C)]`
|
1 - #[repr(transparent)]
1 + #[repr(C)]
|
For more information about this error, try `rustc --explain E0691`.