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/abi.md
+21-21
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,11 @@
2
2
3
3
r[abi]
4
4
5
-
## ABI Compatibility
5
+
## ABI compatibility
6
6
7
7
r[abi.compatibility]
8
8
9
-
r[abi.compatibilty.type]
9
+
r[abi.compatibility.type]
10
10
Two types, `T` and `U`, can be *abi compatible*.
11
11
12
12
r[abi.compatibility.equivalence]
@@ -19,27 +19,27 @@ Two types `T` and `U` are *abi compatible* if:
19
19
> These properties are respectively called "reflexivity", "symmetry", and "transitivity". They ensure that *abi compatibility* is an equivalence relation.
20
20
21
21
r[abi.compatibility.integer]
22
-
Two [integer types] are *abi compatible* if they have the same size and the same signedness
22
+
Two [integer types] are *abi compatible* if they have the same size and the same signedness.
23
23
24
24
> [!NOTE]
25
25
> In particular, `usize` is *abi compatible* with `uN`, and `isize` is *abi compatible* with `iN` where `N` is the target_pointer_width.
26
26
> Two integer types with different signedness, such as `u8` and `i8` are not *abi compatible*.
letx=b'A'asu32; // ascii character indecies are the same as Unicode character indecies
56
+
letx=b'A'asu32; // ascii character indices are the same as Unicode character indices
57
57
lety=f(x);
58
58
assert_eq!(y, 'A');
59
59
}
@@ -108,7 +108,7 @@ The types [`core::mem::MaybeUninit<T>`], [`core::cell::UnsafeCell<T>`], and [`co
108
108
r[abi.compatibility.transparent]
109
109
A [`struct`] declared with the `transparent` representation is *abi compatible* with its field that does not have size 0 and alignment 1, if such a field exists.
110
110
111
-
r[abi.compatibilty.zst]
111
+
r[abi.compatibility.zst]
112
112
Two types, `T` and `U`, are *abi compatible* if both have size 0 and alignment 1.
113
113
114
114
r[abi.compatibility.option]
@@ -138,7 +138,7 @@ Two function signatures are compatible if:
138
138
139
139
r[abi.compatibility.simd-abi]
140
140
A type has *simd abi requirements* if:
141
-
* It is a type declared with the standard-library repr-attrbute`simd`,
141
+
* It is a type declared with the standard-library repr-attribute`simd`, or
142
142
* It is a aggregate type[^1], which has a type with *simd abi requirements* as a field.
143
143
144
144
> [!NOTE]
@@ -158,13 +158,13 @@ A call to a function `f` via a function item or function pointer with a given si
158
158
* The ABI tag of the signature is `extern "Rust"`, or
159
159
* If any parameter type, the return type, or the type of any argument passed via C-varargs has *simd abi requirements*, each [*salient target features*][target_feature] of that type is either set at both the definition site of the function, and at the call site, or is set at neither site.
160
160
161
-
The behaviour a call that is not valid is undefined.
161
+
The behavior of a call that is not valid is undefined.
162
162
163
163
> [!NOTE]
164
-
> When parameter/return types do not exactly match, they are converted as though by calling [`core::mem::transmute`]. The representation and validity requirements of the type in the definition/return site still apply, for example, passing `0` to a function pointer `fn(u32)` that points to a function declared as `fn foo(x: NonZeroU32)` is undefined behaviour.
164
+
> When parameter or return types do not exactly match, they are converted as though by calling [`core::mem::transmute`]. The representation and validity requirements of the type in the definition or return site still apply. For example, passing `0` to a function pointer `fn(u32)` that points to a function declared as `fn foo(x: NonZeroU32)` is undefined behavior.
165
165
166
166
> [!NOTE]
167
-
> the ABI tag `extern "Rust"` is the default when the `extern` keyword is not used (either to declare the function within an [`extern` block], or as a [function qualifier][extern functions]). Thus it is safe to call most functions that use simd types.
167
+
> The ABI tag `extern "Rust"` is the default when the `extern` keyword is not used (either to declare the function within an [`extern` block], or as a [function qualifier][extern functions]). Thus it is safe to call most functions that use simd types.
168
168
169
169
[^1]: The aggregate types, for the purposes of this clause, are [`struct`] types, [`enum`] types, [`union`] types, and [array] types.
170
170
@@ -185,9 +185,9 @@ The behaviour a call that is not valid is undefined.
185
185
186
186
r[abi.used]
187
187
188
-
```abnf
189
-
MetaItemUsed := "used"
190
-
```
188
+
> **<sup>Attribute Syntax</sup>**\
189
+
> _MetaItemUsed_ :\
190
+
> `used`
191
191
192
192
r[abi.used.syntax]
193
193
The *`used` attribute* may be specified as a built-in attribute, using the [_MetaWord_] syntax.
fn __foo(x: i32) -> i32; // error: not a free function, impl method, or static
279
279
}
280
280
```
281
281
@@ -284,7 +284,7 @@ extern "C" {
284
284
285
285
286
286
r[abi.symbol-name.exported]
287
-
An item with either the *`no_mangle`attrbute* or the *`export_name` attribute* is an *exported item*.
287
+
An item with either the *`no_mangle`attribute* or the *`export_name` attribute* is an *exported item*.
288
288
289
289
r[abi.symbol-name.no_mangle]
290
290
The *`no_mangle` attribute* may be specified as a built-in attribute, using the [_MetaWord_] syntax. The *export name* of an item with the *`no_mangle` attribute* is the declaration name of the item.
0 commit comments