@@ -141,24 +141,21 @@ struct Zst2(Zst1, Zst0);
141
141
# }
142
142
```
143
143
144
- #### Default layout of structs where only a single field is not a 1-ZST
144
+ #### Structs with 1-ZST fields
145
145
146
- The default layout of structs where only a single field is not a 1-ZST is the
147
- same as the layout of that non-1-ZST field.
146
+ For the purposes of struct layout [ 1-ZST] fields are ignored.
148
147
149
- For example, the layout of:
148
+ For example,
150
149
151
150
``` rust
152
- struct SomeStruct (i32 , ());
153
- ```
154
-
155
- is the same as the layout of ` i32 ` , but the layout of:
151
+ type Zst1 = ();
152
+ struct S1 (i32 , Zst1 );
156
153
157
- ``` rust
158
- #[repr(align(16))] struct Zst ;
159
- struct SomeOtherStruct (i32 , Zst );
154
+ type Zst2 = [u16 ; 0 ];
155
+ struct S2 (Zst2 , Zst1 );
160
156
```
161
- is ** unspecified** , since ` Zst ` is not a [ 1-ZST] .
157
+
158
+ the layout of ` S1 ` is the same as that of ` i32 ` and the layout of ` S2 ` as that of ` Zst2 ` .
162
159
163
160
#### Unresolved questions
164
161
@@ -169,15 +166,6 @@ issue has been opened for further discussion on the repository. This
169
166
section documents the questions and gives a few light details, but the
170
167
reader is referred to the issues for further discussion.
171
168
172
- ** Zero-sized structs ([ #37 ] ).** If you have a struct which --
173
- transitively -- contains no data of non-zero size, then the size of
174
- that struct will be zero as well. These zero-sized structs appear
175
- frequently as exceptions in other layout considerations (e.g.,
176
- single-field structs). An example of such a struct is
177
- ` std::marker::PhantomData ` .
178
-
179
- [ #37 ] : https://github.com/rust-rfcs/unsafe-code-guidelines/issues/37
180
-
181
169
** Homogeneous structs ([ #36 ] ).** If you have homogeneous structs, where all
182
170
the ` N ` fields are of a single type ` T ` , can we guarantee a mapping to
183
171
the memory layout of ` [T; N] ` ? How do we map between the field names
0 commit comments