Skip to content

Commit 8055a35

Browse files
author
Robin Kruppe
authored
repr(transparent): mention align=1 requirement
The RFC and implementation have always required this.
1 parent 55a3f99 commit 8055a35

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/type-layout.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,10 @@ Like all ways to create undefined behavior in safe Rust, this is a bug.
332332

333333
### The `transparent` Representation
334334

335-
The `transparent` representation can only be used on `struct`s that have a
336-
single non-zero sized field and any number of zero-sized fields, including
337-
[`PhantomData<T>`].
335+
The `transparent` representation can only be used on `struct`s that have:
336+
337+
- a single field with non-zero size, and
338+
- any number of fields with size 0 and alignment 1 (e.g. [`PhantomData<T>`]).
338339

339340
Structs with this representation have the same layout and ABI as the single
340341
non-zero sized field.

0 commit comments

Comments
 (0)