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
+25-13Lines changed: 25 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -19,53 +19,53 @@ Two types `T` and `U` are *abi compatible* if:
19
19
> These properties 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 signednes
22
+
Two [integer types] are *abi compatible* if they have the same size and the same signednes
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*.
27
27
28
28
r[abi.compatibility.char]
29
-
The type `char` is *abi compatible* with the type `u32`.
29
+
The type [`char`] is *abi compatible* with the type [`u32`][integer types].
30
30
31
31
r[abi.compatibility.pointer]
32
-
Two pointer types, `*mut T` and `*const U`, are *abi compatible* if the *metadata type*s of `T` and `U` are the same type.
32
+
Two [pointer types], `*mut T` and `*const U`, are *abi compatible* if the *metadata type*s of `T` and `U` are the same type.
33
33
34
34
> [!NOTE]
35
-
> [`Sized`] types have a *metadata type* of `()`.
35
+
> [`core::marker::Sized`] types have a *metadata type* of `()`.
36
36
37
37
> [!NOTE]
38
38
> With transitivity, this applies regardless of the mutability of either pointer type
39
39
40
40
r[abi.compatibility.reference-box]
41
-
The types `&T`, `&mut T`, [`Box<T>`][core::boxed::Box], and [`NonNull<T>`][core::ptr::NonNull], are *abi compatible* with `*const T`
41
+
The types [`&T`], [`&mut T`], [`alloc::boxed::Box<T>`], and [`core::ptr::NonNull<T>`], are *abi compatible* with `*const T`
42
42
43
43
> [!NOTE]
44
44
> With transitivity, they are also *abi compatible* with each other, and with `*mut T`, as well as references/`Box` to different types that have the same *metadata type*.
45
45
46
46
r[abi.compatibility.core]
47
-
The types [`MaybeUninit<T>`][core::mem::MaybeUninit], [`UnsafeCell<T>`][core::cell::UnsafeCell], and [`NonZero<T>`][core::num::NonZero], are *abi compatible* with `T`.
47
+
The types [`core::mem::MaybeUninit<T>`], [`core::cell::UnsafeCell<T>`], and [`core::num::NonZero<T>`], are *abi compatible* with `T`.
48
48
49
49
r[abi.compatibility.transparent]
50
-
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.
50
+
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.
51
51
52
52
r[abi.compatibilty.zst]
53
53
Two types, `T` and `U`, are *abi compatible* if both have size 0 and alignment 1.
54
54
55
55
r[abi.compatibility.option]
56
-
If `T` is a type listed in [layout.enum.option](https://doc.rust-lang.org/stable/core/option/index.html#representation), then given `S` is a type with size 0 and alignment 1, `T` is *abi compatible* with the types [`Option<T>`], [`Result<T,S>`], and [`Result<S,T>`].
56
+
If `T` is a type listed in [layout.enum.option](https://doc.rust-lang.org/stable/core/option/index.html#representation), then given `S` is a type with size 0 and alignment 1, `T` is *abi compatible* with the types [`core::option::Option<T>`], [`core::result::Result<T,S>`], and [`core::result::Result<S,T>`].
57
57
58
58
r[abi.compatibility.fn-ptr]
59
-
An `fn`-ptr type `T` is compatible with an `fn`-ptr type `U` if `T` and `U` have *abi compatible* tags.
59
+
An [`fn`-ptr type]`T` is compatible with an [`fn`-ptr type]`U` if `T` and `U` have *abi compatible* tags.
60
60
61
61
r[abi.compatibility.extern-tag]
62
-
Two [abi tags][abi] are *abi compatible* if:
62
+
Two [abi tags][abi tag] are *abi compatible* if:
63
63
* They are the same string, or
64
64
* One tag is `"X"`, and the other is `"X-unwind"`
65
65
66
66
r[abi.compatibility.signature]
67
67
Two function signatures are compatible if:
68
-
* The [abi tags][abi] of both signatures are *abi compatible*,
68
+
* The [abi tags][abi tag] of both signatures are *abi compatible*,
69
69
* They have the same number of parameters, excluding C-varargs,
70
70
* Each parameter of both signatures, in order, are *abi compatible*, and
71
71
* Either both signatures have C-varargs, or neither signature does.
@@ -76,7 +76,7 @@ Two function signatures are compatible if:
76
76
r[abi.compatibility.simd-abi]
77
77
A type has *simd abi requirements* if:
78
78
* It is a type declared with the standard-library repr-attrbute `simd`,
79
-
* It is a aggregate type, which has a type with *simd abi requirements* as a field.
79
+
* It is a aggregate type[^1], which has a type with *simd abi requirements* as a field.
80
80
81
81
> [!NOTE]
82
82
> The `repr(simd)` attribute cannot be used by Rust code, only by the standard library.
@@ -100,6 +100,8 @@ The behaviour a call that is not valid is undefined.
100
100
> [!NOTE]
101
101
> 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.
102
102
103
+
[^1]: The aggregate types, for the purposes of this clause, are [`struct`] types, [`enum`] types, [`union`] types, and [array] types.
0 commit comments