Auto merge of #115334 - RalfJung:transparent-aligned-zst, r=compiler-errors
repr(transparent): it's fine if the one non-1-ZST field is a ZST This code currently gets rejected: ```rust #[repr(transparent)] struct MyType([u16; 0]) ``` That clearly seems like a bug to me: `repr(transparent)` [got defined ](https://github.com/rust-lang/rust/issues/77841#issuecomment-716575747) as having any number of 1-ZST fields plus optionally one more field; `MyType` clearly satisfies that definition. This PR changes the `repr(transparent)` logic to actually match that definition.
This commit is contained in:
commit
203c57dbe2
5 changed files with 91 additions and 88 deletions
|
@ -1,9 +1,11 @@
|
|||
#### Note: this error code is no longer emitted by the compiler.
|
||||
|
||||
A struct, enum, or union with the `repr(transparent)` representation hint
|
||||
contains a zero-sized field that requires non-trivial alignment.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0691
|
||||
```ignore (error is no longer emitted)
|
||||
#![feature(repr_align)]
|
||||
|
||||
#[repr(align(32))]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue