Skip to content

Commit

Permalink
Merge pull request rust-lang#737 from rkruppe/patch-2
Browse files Browse the repository at this point in the history
repr(transparent): mention align=1 requirement
  • Loading branch information
Centril authored Jan 11, 2020
2 parents 55a3f99 + 8055a35 commit a94b0ef
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/type-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>`].
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<T>`]).

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

0 comments on commit a94b0ef

Please sign in to comment.