You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/type-layout.md
+6-10Lines changed: 6 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -164,19 +164,15 @@ r[layout.repr.rust.intro]
164
164
The `Rust` representation is the default representation for nominal types without a `repr` attribute. Using this representation explicitly through a `repr` attribute is guaranteed to be the same as omitting the attribute entirely.
165
165
166
166
r[layout.repr.rust.layout]
167
-
The only data layout guarantees made by this representation are those required for soundness. They are:
167
+
The only data layout guarantees made by this representation are those required for soundness. These are:
168
168
169
-
1. The fields are properly aligned.
170
-
2. The fields do not overlap.
171
-
3. The alignment of the type is at least the maximum alignment of its fields.
169
+
1. The offset of a field is divisible by that field's alignment.
170
+
2. The alignment of the type is at least the maximum alignment of its fields.
172
171
173
-
r[layout.repr.rust.alignment]
174
-
Formally, the first guarantee means that the offset of any field is divisible by that field's alignment.
172
+
r[layout.repr.rust.layout.struct]
173
+
For [structs], it is further guaranteed that the fields do not overlap. That is, the fields can be ordered such that the offset plus the size of any field is less than or equal to the offset of the next field in the ordering. The ordering does not have to be the same as the order in which the fields are specified in the declaration of the type.
175
174
176
-
r[layout.repr.rust.field-storage]
177
-
The second guarantee means that the fields can be ordered such that the offset plus the size of any field is less than or equal to the offset of the next field in the ordering. The ordering does not have to be the same as the order in which the fields are specified in the declaration of the type.
178
-
179
-
Be aware that the second guarantee does not imply that the fields have distinct addresses: zero-sized types may have the same address as other fields in the same struct.
175
+
Be aware that this guarantee does not imply that the fields have distinct addresses: zero-sized types may have the same address as other fields in the same struct.
180
176
181
177
r[layout.repr.rust.unspecified]
182
178
There are no other guarantees of data layout made by this representation.
0 commit comments