@@ -88,9 +88,9 @@ String slices are a UTF-8 representation of characters that have the same layout
88
88
89
89
## Tuple Layout
90
90
91
- Tuples do not have any guarantees about their layout .
91
+ Tuples are laid out according to the [ default representation ] [ Default ] .
92
92
93
- The exception to this is the unit tuple (` () ` ) which is guaranteed as a
93
+ The exception to this is the unit tuple (` () ` ), which is guaranteed as a
94
94
zero-sized type to have a size of 0 and an alignment of 1.
95
95
96
96
## Trait Object Layout
@@ -164,7 +164,25 @@ representation will not change the layout of `Inner`.
164
164
Nominal types without a ` repr ` attribute have the default representation.
165
165
Informally, this representation is also called the ` rust ` representation.
166
166
167
- There are no guarantees of data layout made by this representation.
167
+ The only data layout guarantees made by this representation are those required
168
+ for soundness. They are:
169
+
170
+ 1 . The fields are properly aligned.
171
+ 2 . The fields do not overlap.
172
+ 3 . The alignment of the type is at least the maximum alignment of its fields.
173
+
174
+ Formally, the first guarantee means that the offset of any field is divisible by
175
+ that field's alignment. The second guarantee means that the fields can be
176
+ ordered such that the offset plus the size of any field is less than or equal to
177
+ the offset of the next field in the ordering. The ordering does not have to be
178
+ the same as the order in which the fields are specified in the declaration of
179
+ the type.
180
+
181
+ Be aware that the second guarantee does not imply that the fields have distinct
182
+ addresses: zero-sized types may have the same address as other fields in the
183
+ same struct.
184
+
185
+ There are no other guarantees of data layout made by this representation.
168
186
169
187
### The ` C ` Representation
170
188
0 commit comments