Skip to content

Commit 0c95719

Browse files
committed
Make suggested changes from PR comments
1 parent 83a3b71 commit 0c95719

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/abi.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Two types `T` and `U` are *abi compatible* if:
1616
* There exists a type `V`, such that `T` is *abi compatible* with `V` an `V` is *abi compatible* with `U`,
1717

1818
> [!NOTE]
19-
> These properties ensure that *abi compatibility* is an equivalence relation.
19+
> These properties are respectively called "reflexivity", "symmetry", and "transitivity". They ensure that *abi compatibility* is an equivalence relation.
2020
2121
r[abi.compatibility.integer]
2222
Two [integer types] are *abi compatible* if they have the same size and the same signedness
@@ -69,13 +69,13 @@ Two [pointer types], `*mut T` and `*const U`, are *abi compatible* if the *metad
6969
> With transitivity, this applies regardless of the mutability of either pointer type
7070
7171
```rust
72-
unsafe fn foo(x: *mut i32){
72+
unsafe fn foo(x: *mut u32){
7373
unsafe{x.write(5);}
7474
}
7575

7676
fn main(){
7777
let f: unsafe fn(*mut ()) = unsafe{core::mem::transmute(foo as unsafe fn(_))}; // Type Erase the function
78-
let mut val = 0;
78+
let mut val: u32 = 0;
7979
let ptr = core::ptr::addr_of_mut!(val).cast::<()>(); // Get Opaque Userdata from somewhere
8080
unsafe{f(ptr);}
8181
assert_eq!(val, 5);
@@ -116,13 +116,16 @@ If `T` is a type listed in [layout.enum.option](https://doc.rust-lang.org/stable
116116

117117

118118
r[abi.compatibility.fn-ptr]
119-
An [`fn`-ptr type] `T` is compatible with an [`fn`-ptr type] `U` if `T` and `U` have *abi compatible* tags.
119+
An [`fn`-ptr type] `T` is *abi compatible* with an [`fn`-ptr type] `U` if `T` and `U` have *abi compatible* tags.
120120

121121
r[abi.compatibility.extern-tag]
122122
Two [abi tags][abi tag] are *abi compatible* if:
123123
* They are the same string, or
124124
* One tag is `"X"`, and the other is `"X-unwind"`
125125

126+
> [!NOTE]
127+
> e.g. `extern "C"` and `extern "C-unwind"` are compatible with each other.
128+
126129
r[abi.compatibility.signature]
127130
Two function signatures are compatible if:
128131
* The [abi tags][abi tag] of both signatures are *abi compatible*,

0 commit comments

Comments
 (0)