|
1 | 1 | ## Glossary
|
2 | 2 |
|
| 3 | +### ABI (of a type) |
| 4 | +[abi]: #abi-of-a-type |
| 5 | + |
| 6 | +The *function call ABI* or short *ABI* of a type defines how it is passed *by-value* across a function boundary. |
| 7 | +Possible ABIs include passing the value directly in zero or more registers, or passing it indirectly as a pointer to the actual data. |
| 8 | +The space of all possible ABIs is huge and extremely target-dependent. |
| 9 | +Rust therefore does generally not clearly define the ABI of any type, it only defines when two types are *ABI-compatible*, |
| 10 | +which means that it is legal to call a function declared with an argument or return type `T` using a declaration or function pointer with argument or return type `U`. |
| 11 | + |
| 12 | +Note that ABI compatibility is stricter than layout compatibility. |
| 13 | +For instance `#[repr(C)] struct S(i32)` is (guaranteed to be) layout-compatible with `i32`, but it is *not* ABI-compatible. |
| 14 | + |
3 | 15 | ### Abstract Byte
|
4 | 16 | [abstract byte]: #abstract-byte
|
5 | 17 |
|
@@ -100,13 +112,15 @@ All interior mutation in Rust has to happen inside an [`UnsafeCell`](https://doc
|
100 | 112 | ### Layout
|
101 | 113 | [layout]: #layout
|
102 | 114 |
|
103 |
| -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). |
104 |
| -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. |
| 115 | +The *layout* of a type defines its size and alignment as well as the offsets of its subobjects (e.g. fields of structs/unions/enums/... or elements of arrays, and the discriminant of enums). |
| 116 | + |
| 117 | +Note that layout does not capture everything that there is to say about how a type is represented on the machine; it notably does not include [ABI][abi] or [Niches][niche]. |
105 | 118 |
|
106 | 119 | Note: Originally, *layout* and *representation* were treated as synonyms, and Rust language features like the `#[repr]` attribute reflect this.
|
107 |
| -In this document, *layout* and *representation* are not synonyms. |
| 120 | +In this document, *layout* and [*representation*][representation relation] are not synonyms. |
108 | 121 |
|
109 | 122 | ### Niche
|
| 123 | +[niche]: #niche |
110 | 124 |
|
111 | 125 | The *niche* of a type determines invalid bit-patterns that will be used by layout optimizations.
|
112 | 126 |
|
|
0 commit comments