Skip to content

Commit 4442b41

Browse files
committed
Add note to ZST struct section
1 parent eae3f3c commit 4442b41

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

reference/src/layout/structs-and-tuples.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,10 @@ struct S3(Zst1); // same layout as Zst1
146146

147147
#### Zero-sized structs
148148

149-
For `repr(Rust)`, `repr(packed(N))`, `repr(align(N))`, and `repr(C)`
150-
structs: if all fields of a struct have size 0, then the struct has size 0.
149+
For `repr(Rust)`, `repr(packed(N))`, `repr(align(N))`, and `repr(C)` structs: if
150+
all fields of a struct have size 0, then the struct has size 0. In particular, a
151+
struct with no fields is a ZST, and if it has no repr attribute it is moreover a
152+
1-ZST as it also has no alignment requirements.
151153

152154
For example, all these types are zero-sized:
153155

0 commit comments

Comments
 (0)