@@ -86,9 +86,10 @@ String slices are a UTF-8 representation of characters that have the same layout
86
86
87
87
## Tuple Layout
88
88
89
- Tuples do not have any guarantees about their layout.
89
+ Tuples have the same layout guarantees a struct with the same fields laid out
90
+ according to the default struct representation.
90
91
91
- The exception to this is the unit tuple (` () ` ) which is guaranteed as a
92
+ The exception to this is the unit tuple (` () ` ), which is guaranteed as a
92
93
zero-sized type to have a size of 0 and an alignment of 1.
93
94
94
95
## Trait Object Layout
@@ -162,7 +163,24 @@ representation will not change the layout of `Inner`.
162
163
Nominal types without a ` repr ` attribute have the default representation.
163
164
Informally, this representation is also called the ` rust ` representation.
164
165
165
- There are no guarantees of data layout made by this representation.
166
+ There are very few data layout guarantees made by this representation. The only
167
+ guarantees are:
168
+
169
+ 1 . The fields of the struct are properly aligned.
170
+ 2 . The fields do not overlap.
171
+ 3 . The alignment of the struct is not less than the alignment of any of its
172
+ fields.
173
+
174
+ Formally, the first guarantee means that the offset of any field in the struct
175
+ is divisible by that field's alignment. The second guarantee means that the
176
+ fields can be ordered such that the offset plus the size of any field is less
177
+ than or equal to the offset of the next field in the ordering. The ordering does
178
+ not have to be the same as the order in which the field are specified in the
179
+ declaration of the struct.
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.
166
184
167
185
### The ` C ` Representation
168
186
0 commit comments