Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak repr(transparent) to mention requiring *at most* one non-1-ZST #1568

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
compiler-errors marked this conversation as resolved.
Show resolved Hide resolved

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