@@ -122,6 +122,12 @@ compiler will not reorder it, to allow for the possibility of
122
122
unsizing. E.g., ` struct Foo { x: u16, y: u32 } ` and `struct Foo<T > {
123
123
x: u16, y: T }` where ` T = u32` are not guaranteed to be identical.
124
124
125
+ #### Zero-sized structs
126
+
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.
130
+
125
131
#### Unresolved questions
126
132
127
133
During the course of the discussion in [ #11 ] and [ #12 ] , various
@@ -131,15 +137,6 @@ issue has been opened for further discussion on the repository. This
131
137
section documents the questions and gives a few light details, but the
132
138
reader is referred to the issues for further discussion.
133
139
134
- ** Zero-sized structs ([ #37 ] ).** If you have a struct which --
135
- transitively -- contains no data of non-zero size, then the size of
136
- that struct will be zero as well. These zero-sized structs appear
137
- frequently as exceptions in other layout considerations (e.g.,
138
- single-field structs). An example of such a struct is
139
- ` std::marker::PhantomData ` .
140
-
141
- [ #37 ] : https://github.com/rust-rfcs/unsafe-code-guidelines/issues/37
142
-
143
140
** Single-field structs ([ #34 ] ).** If you have a struct with single field
144
141
(` struct Foo { x: T } ` ), should we guarantee that the memory layout of
145
142
` Foo ` is identical to the memory layout of ` T ` (note that ABI details
0 commit comments