Skip to content

Commit 12b9c0c

Browse files
committed
Add links to clauses in abi chapter
1 parent 617f07e commit 12b9c0c

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

src/abi.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,53 +19,53 @@ Two types `T` and `U` are *abi compatible* if:
1919
> These properties ensure that *abi compatibility* is an equivalence relation.
2020
2121
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
2323

2424
> [!NOTE]
2525
> In particular, `usize` is *abi compatible* with `uN`, and `isize` is *abi compatible* with `iN` where `N` is the target_pointer_width.
2626
> Two integer types with different signedness, such as `u8` and `i8` are not *abi compatible*.
2727
2828
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].
3030

3131
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.
3333

3434
> [!NOTE]
35-
> [`Sized`] types have a *metadata type* of `()`.
35+
> [`core::marker::Sized`] types have a *metadata type* of `()`.
3636
3737
> [!NOTE]
3838
> With transitivity, this applies regardless of the mutability of either pointer type
3939
4040
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`
4242

4343
> [!NOTE]
4444
> 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*.
4545
4646
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`.
4848

4949
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.
5151

5252
r[abi.compatibilty.zst]
5353
Two types, `T` and `U`, are *abi compatible* if both have size 0 and alignment 1.
5454

5555
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>`].
5757

5858
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.
6060

6161
r[abi.compatibility.extern-tag]
62-
Two [abi tags][abi] are *abi compatible* if:
62+
Two [abi tags][abi tag] are *abi compatible* if:
6363
* They are the same string, or
6464
* One tag is `"X"`, and the other is `"X-unwind"`
6565

6666
r[abi.compatibility.signature]
6767
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*,
6969
* They have the same number of parameters, excluding C-varargs,
7070
* Each parameter of both signatures, in order, are *abi compatible*, and
7171
* Either both signatures have C-varargs, or neither signature does.
@@ -76,7 +76,7 @@ Two function signatures are compatible if:
7676
r[abi.compatibility.simd-abi]
7777
A type has *simd abi requirements* if:
7878
* 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.
8080

8181
> [!NOTE]
8282
> 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.
100100
> [!NOTE]
101101
> 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.
102102
103+
[^1]: The aggregate types, for the purposes of this clause, are [`struct`] types, [`enum`] types, [`union`] types, and [array] types.
104+
103105
[`__m128`]: https://doc.rust-lang.org/stable/core/arch/x86_64/struct.__m128.html
104106
[`__m128i`]: https://doc.rust-lang.org/stable/core/arch/x86_64/struct.__m128i.html
105107
[`__m128f`]: https://doc.rust-lang.org/stable/core/arch/x86_64/struct.__m128f.html
@@ -246,8 +248,18 @@ pub static VAR1: u32 = 1;
246248
[attribute]: attributes.md
247249
[extern functions]: items/functions.md#extern-function-qualifier
248250
[`extern` block]: items/external-blocks.md
249-
[abi]: items/external-blocks.md#abi
251+
[abi tag]: items/external-blocks.md#abi
250252
[function]: items/functions.md
253+
[`fn`-ptr type]: types/function-pointer.md
254+
[integer types]: types/numeric.md#integer-types
255+
[`char`]: types/textual.md
256+
[pointer types]: types/pointer.md#raw-pointers-const-and-mut
257+
[`&T`]: types/pointer.md#shared-references-
258+
[`&mut T`]: types/pointer.md#mutable-references-mut
259+
[`struct`]: types/struct.md
260+
[`enum`]: types/enum.md
261+
[`union`]: types/union.md
262+
[array]: types/array.md
251263
[item]: items.md
252264
[static]: items/static-items.md
253265
[target_feature]: attributes/codegen.md#the-target_feature-attribute

0 commit comments

Comments
 (0)