From 8055a35c909a34752eb4d5a367f3798d6089b0a3 Mon Sep 17 00:00:00 2001 From: Robin Kruppe Date: Sat, 11 Jan 2020 11:36:05 +0100 Subject: [PATCH] repr(transparent): mention align=1 requirement The RFC and implementation have always required this. --- src/type-layout.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/type-layout.md b/src/type-layout.md index 900c6d4ac..f6c9ca77e 100644 --- a/src/type-layout.md +++ b/src/type-layout.md @@ -332,9 +332,10 @@ Like all ways to create undefined behavior in safe Rust, this is a bug. ### The `transparent` Representation -The `transparent` representation can only be used on `struct`s that have a -single non-zero sized field and any number of zero-sized fields, including -[`PhantomData`]. +The `transparent` representation can only be used on `struct`s that have: + +- a single field with non-zero size, and +- any number of fields with size 0 and alignment 1 (e.g. [`PhantomData`]). Structs with this representation have the same layout and ABI as the single non-zero sized field.