@@ -1529,16 +1529,20 @@ mod prim_ref {}
1529
1529
///
1530
1530
/// ### ABI compatibility
1531
1531
///
1532
- /// Generally, when a function is declared with one signature and called via a function pointer
1533
- /// with a different signature, the two signatures must be *ABI-compatible* or else this call is
1532
+ /// Generally, when a function is declared with one signature and called via a function pointer with
1533
+ /// a different signature, the two signatures must be *ABI-compatible* or else this call is
1534
1534
/// Undefined Behavior. ABI compatibility is a lot stricter than merely having the same
1535
1535
/// representation in memory; for example, even if `i32` and `f32` have the same size and alignment,
1536
1536
/// they might be passed in different registers and hence not be ABI-compatible.
1537
1537
///
1538
- /// For two signatures to be considered *ABI-compatible*, they must declare the same `extern` ABI
1539
- /// string, must take the same number of arguments, and the individual argument types and the return
1540
- /// types must be ABI-compatible.
1541
- /// The relation of when two types are ABI-compatible is defined as follows:
1538
+ /// For two signatures to be considered *ABI-compatible*, they must use a compatible call ABI (as
1539
+ /// declared via `extern "ABI"`), must take the same number of arguments, and the individual
1540
+ /// argument types and the return types must be ABI-compatible.
1541
+ ///
1542
+ /// The call ABIs are guaranteed to be compatible if they are the same, or if the caller ABI is
1543
+ /// `$X-unwind` and the callee ABI is `$X`.
1544
+ ///
1545
+ /// The following types are guaranteed to be ABI-compatible:
1542
1546
///
1543
1547
/// - Every type is ABI-compatible with itself.
1544
1548
/// - If `<T as Pointee>::Metadata == ()`, then `*const T`, `*mut T`, `&T`, `&mut T`, `Box<T>`,
@@ -1555,17 +1559,20 @@ mod prim_ref {}
1555
1559
/// field type was changed from `T1` to `T2` are ABI-compatible.
1556
1560
/// - ABI-compatibility is symmetric and transitive.
1557
1561
///
1558
- /// Noteworthy cases of types *not* being ABI-compatible are `bool` vs `u8`, and `i32` vs `u32`: on
1559
- /// some targets, the calling conventions for these types differ in terms of what they guarantee for
1560
- /// the remaining bits in the register that are not used by the value. `i32` vs `f32` has already
1561
- /// been mentioned above.
1562
+ /// More signatures can be ABI-compatible on specific targets, but that should not be relied upon
1563
+ /// since it is not portable and not a stable guarantee.
1564
+ ///
1565
+ /// Noteworthy cases of types *not* being ABI-compatible in general are `bool` vs `u8`, and `i32` vs
1566
+ /// `u32`: on some targets, the calling conventions for these types differ in terms of what they
1567
+ /// guarantee for the remaining bits in the register that are not used by the value. `i32` vs `f32`
1568
+ /// has already been mentioned above.
1562
1569
///
1563
1570
/// Note that these rules describe when two completely known types are ABI-compatible. When
1564
1571
/// considering ABI compatibility of a type declared in another crate (including the standard
1565
1572
/// library), consider that any type that has a private field or the `#[non_exhaustive]` attribute
1566
1573
/// may change its layout as a non-breaking update unless documented otherwise -- so for instance,
1567
1574
/// even if such a type is a 1-ZST or `repr(transparent)` right now, this might change with any
1568
- /// library version change .
1575
+ /// library version bump .
1569
1576
///
1570
1577
/// ### Trait implementations
1571
1578
///
0 commit comments