From 8154cd1c1dba4cdfdcfe568a8bdf6e14d8db6367 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Mon, 12 Aug 2024 20:13:57 -0400 Subject: [PATCH] Tweak repr(transparent) --- src/type-layout.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/type-layout.md b/src/type-layout.md index c53e9d097..4f7575f34 100644 --- a/src/type-layout.md +++ b/src/type-layout.md @@ -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`]). +- any number of fields with size 0 and alignment 1 (e.g. [`PhantomData`]), 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`