Skip to content

Commit 83e9f3d

Browse files
committed
Hyperlink all the things
1 parent 080d63e commit 83e9f3d

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

reference/src/glossary.md

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ Accordingly, we say that a library (or an individual function) is *sound* if it
171171
Conversely, the library/function is *unsound* if safe code *can* cause Undefined Behavior.
172172

173173
#### Layout
174+
[layout]: #layout
174175

175176
The *layout* of a type defines its size and alignment as well as the offsets of its subobjects (e.g. fields of structs/unions/enum/... or elements of arrays).
176177
Moreover, the layout of a type records its *function call ABI* (or just *ABI* for short): how the type is passed *by value* across a function boundary.

reference/src/layout/unions.md

+11-8
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,27 @@ A union consists of several variants, one for each field. All variants have the
1212
same size and start at the same memory address, such that in memory the variants
1313
overlap. This can be visualized as follows:
1414

15-
```rust,ignore
15+
```text
1616
[ <--> [field0_ty] <----> ]
1717
[ <----> [field1_ty] <--> ]
1818
[ <---> [field2_ty] <---> ]
1919
```
2020

2121
> **Figure: union field layout**: Each row in the picture shows the layout of
2222
> the union for each of its fields, where the square brackets `[]` depict an
23-
> array of bytes, `<-...->` denotes different amount of padding, and
23+
> array of bytes, `<-...->` denotes different amount of [padding], and
2424
> `[field{i}_ty]` is the bytes of the type of the `i`-th union field.
2525
2626
The individual fields (`[field{i}_ty_]`) are blocks of fixed size determined by
27-
the field's layout. The only degrees of freedom the compiler has when computing
28-
the layout of a union are the size of the union, which can be larger than the
29-
size of its largest field, and the offset of each union field within its
30-
variant. How these are picked depends on certain constraints, lik for example,
31-
the alignment requirements of the fields, the `#[repr]` attribute of the
32-
`union`, etc.
27+
the field's [layout]. The only degrees of freedom the compiler has when
28+
computing the layout of a union are the size of the union, which can be larger
29+
than the size of its largest field, and the offset of each union field within
30+
its variant. How these are picked depends on certain constraints like, for
31+
example, the alignment requirements of the fields, the `#[repr]` attribute of
32+
the `union`, etc.
33+
34+
[padding]: ../glossary.md#padding
35+
[layout]: ../glossary.md#layout
3336

3437
### Unions with default layout ("`repr(Rust)`")
3538

0 commit comments

Comments
 (0)