Skip to content

Commit effbdc1

Browse files
authored
Merge pull request #1396 from Centri3/repr-rust
Update section on default layout for `repr(Rust)`
2 parents 3c36417 + 9f9e7a7 commit effbdc1

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/type-layout.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ String slices are a UTF-8 representation of characters that have the same layout
8888

8989
## Tuple Layout
9090

91-
Tuples are laid out according to the [default representation][Default].
91+
Tuples are laid out according to the [`Rust` representation][`Rust`].
9292

9393
The exception to this is the unit tuple (`()`), which is guaranteed as a
9494
zero-sized type to have a size of 0 and an alignment of 1.
@@ -110,7 +110,7 @@ All user-defined composite types (`struct`s, `enum`s, and `union`s) have a
110110
*representation* that specifies what the layout is for the type. The possible
111111
representations for a type are:
112112

113-
- [Default]
113+
- [`Rust`] (default)
114114
- [`C`]
115115
- The [primitive representations]
116116
- [`transparent`]
@@ -159,10 +159,12 @@ not change the layout of the fields themselves. For example, a struct with a
159159
`C` representation that contains a struct `Inner` with the default
160160
representation will not change the layout of `Inner`.
161161

162-
### The Default Representation
162+
### <a id="the-default-representation"></a> The `Rust` Representation
163163

164-
Nominal types without a `repr` attribute have the default representation.
165-
Informally, this representation is also called the `rust` representation.
164+
The `Rust` representation is the default representation for nominal types
165+
without a `repr` attribute. Using this representation explicitly through a
166+
`repr` attribute is guaranteed to be the same as omitting the attribute
167+
entirely.
166168

167169
The only data layout guarantees made by this representation are those required
168170
for soundness. They are:
@@ -543,7 +545,7 @@ important consequence of these rules is that a type with `#[repr(packed(1))]`
543545

544546
The `align` and `packed` modifiers cannot be applied on the same type and a
545547
`packed` type cannot transitively contain another `align`ed type. `align` and
546-
`packed` may only be applied to the [default] and [`C`] representations.
548+
`packed` may only be applied to the [`Rust`] and [`C`] representations.
547549

548550
The `align` modifier can also be applied on an `enum`.
549551
When it is, the effect on the `enum`'s alignment is the same as if the `enum`
@@ -604,7 +606,7 @@ used with any other representation.
604606
[undefined behavior]: behavior-considered-undefined.md
605607
[55149]: https://github.com/rust-lang/rust/issues/55149
606608
[`PhantomData<T>`]: special-types-and-traits.md#phantomdatat
607-
[Default]: #the-default-representation
609+
[`Rust`]: #the-rust-representation
608610
[`C`]: #the-c-representation
609611
[primitive representations]: #primitive-representations
610612
[structs]: items/structs.md

0 commit comments

Comments
 (0)