Skip to content

Commit c847771

Browse files
committed
Extend the guarantee to types with default layout but increased alignment
1 parent 6e4d2c3 commit c847771

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ x: u16, y: T }` where `T = u32` are not guaranteed to be identical.
124124

125125
#### Zero-sized structs
126126

127-
Structs with default layout are zero-sized, if they contain no fields of
128-
non-zero size. That is, either the type has no fields, or all of its fields have
129-
zero size.
127+
Structs with default layout or default layout with increased alignment are
128+
zero-sized, if they contain no fields of non-zero size. That is, either the type
129+
has no fields, or all of its fields have zero size.
130130

131131
For example, all these types are zero-sized:
132132

133133
```rust
134134
# use std::mem::size_of;
135-
struct Zst0;
135+
#[repr(align(32))] struct Zst0;
136136
struct Zst1(Zst0);
137137
struct Zst2(Zst1, Zst0);
138138
# fn main() {

0 commit comments

Comments
 (0)