@@ -1544,28 +1544,35 @@ mod prim_ref {}
1544
1544
///
1545
1545
/// The following types are guaranteed to be ABI-compatible:
1546
1546
///
1547
- /// - Every type is ABI-compatible with itself.
1548
1547
/// - `*const T`, `*mut T`, `&T`, `&mut T`, `Box<T>`, `NonNull<T>` are all ABI-compatible with each
1549
1548
/// other for all `T`.
1550
- /// - Any two `fn()` types with the same `extern` ABI string are ABI-compatible with each other.
1551
- /// - Any two 1-ZST types (types with size 0 and alignment 1) are ABI-compatible.
1552
- /// - A `repr(transparent)` type `T` is ABI-compatible with its unique non-1-ZST field (if there is
1553
- /// such a field).
1549
+ /// - Any two `fn`/`extern "ABI" fn` types with the same call ABI are ABI-compatible with each
1550
+ /// other, independent of the rest of their signature.
1551
+ /// - Any two types with size 0 and alignment 1 are ABI-compatible.
1552
+ /// - A `repr(transparent)` type `T` is ABI-compatible with its unique non-trivial field, i.e., the
1553
+ /// unique field that doesn't have size 0 and alignment 1 (if there is such a field).
1554
1554
/// - `i32` is ABI-compatible with `NonZeroI32`, and similar for all other integer types with their
1555
1555
/// matching `NonZero*` type.
1556
1556
/// - If `T` is guaranteed to be subject to the [null pointer
1557
1557
/// optimization](option/index.html#representation), then `T` and `Option<T>` are ABI-compatible.
1558
+ ///
1559
+ /// Furthermore, ABI compatibility satisfies the following general properties:
1560
+ ///
1561
+ /// - Every type is ABI-compatible with itself.
1558
1562
/// - If `T1` and `T2` are ABI-compatible, then two `repr(C)` types that only differ because one
1559
1563
/// field type was changed from `T1` to `T2` are ABI-compatible.
1560
- /// - ABI-compatibility is symmetric and transitive.
1564
+ /// - If `T1` and `T2` are ABI-compatible and `T2` and `T3` are ABI-compatible, then so are `T1` and
1565
+ /// `T3` (i.e., ABI-compatibility is transitive).
1566
+ /// - If `T1` and `T2` are ABI-compatible, then so are `T2` and `T1` (i.e., ABI-compatibility is
1567
+ /// symmetric).
1561
1568
///
1562
1569
/// More signatures can be ABI-compatible on specific targets, but that should not be relied upon
1563
1570
/// since it is not portable and not a stable guarantee.
1564
1571
///
1565
1572
/// Noteworthy cases of types *not* being ABI-compatible in general are `bool` vs `u8`, and `i32` vs
1566
1573
/// `u32`: on some targets, the calling conventions for these types differ in terms of what they
1567
1574
/// guarantee for the remaining bits in the register that are not used by the value. `i32` vs `f32`
1568
- /// has already been mentioned above.
1575
+ /// are not compatible either, as has already been mentioned above.
1569
1576
///
1570
1577
/// Note that these rules describe when two completely known types are ABI-compatible. When
1571
1578
/// considering ABI compatibility of a type declared in another crate (including the standard
0 commit comments