Skip to content

Commit

Permalink
Merge pull request #1568 from compiler-errors/repr-transparent
Browse files Browse the repository at this point in the history
Tweak `repr(transparent)` to mention requiring *at most* one non-1-ZST
  • Loading branch information
traviscross authored Aug 20, 2024
2 parents b1fced7 + 8154cd1 commit 9c0e24b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/type-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -585,12 +585,11 @@ was wrapped in a newtype `struct` with the same `align` modifier.
The `transparent` representation can only be used on a [`struct`][structs]
or an [`enum`][enumerations] with a single variant that has:
- a single field with non-zero size, and
- any number of fields with size 0 and alignment 1 (e.g. [`PhantomData<T>`]).
- any number of fields with size 0 and alignment 1 (e.g. [`PhantomData<T>`]), and
- at most one other field.
Structs and enums with this representation have the same layout and ABI
as the single non-zero sized field.
as the only non-size 0 non-alignment 1 field, if present, or unit otherwise.
This is different than the `C` representation because
a struct with the `C` representation will always have the ABI of a `C` `struct`
Expand Down

0 comments on commit 9c0e24b

Please sign in to comment.