Skip to content

Commit

Permalink
Auto merge of rust-lang#132200 - Mark-Simulacrum:strengthen-cross-lan…
Browse files Browse the repository at this point in the history
…g, r=RalfJung

Make clearer that guarantees in ABI compatibility are for Rust only

cc rust-lang#132136 (comment) -- it looks like we already had a note that I missed in my initial look here, but this goes further to emphasize the guarantees, including uplifting it to the top of the general documentation.

r? `@RalfJung`
  • Loading branch information
bors committed Oct 28, 2024
2 parents cde6279 + ec76942 commit e212260
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/src/primitive_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,9 @@ mod prim_ref {}
/// pointers, make your type [`Option<fn()>`](core::option#options-and-pointers-nullable-pointers)
/// with your required signature.
///
/// Note that FFI requires additional care to ensure that the ABI for both sides of the call match.
/// The exact requirements are not currently documented.
///
/// ### Safety
///
/// Plain function pointers are obtained by casting either plain functions, or closures that don't
Expand Down Expand Up @@ -1750,8 +1753,13 @@ mod prim_ref {}
/// is also used rarely. So, most likely you do not have to worry about ABI compatibility.
///
/// But assuming such circumstances, what are the rules? For this section, we are only considering
/// the ABI of direct Rust-to-Rust calls, not linking in general -- once functions are imported via
/// `extern` blocks, there are more things to consider that we do not go into here.
/// the ABI of direct Rust-to-Rust calls (with both definition and callsite visible to the
/// Rust compiler), not linking in general -- once functions are imported via `extern` blocks, there
/// are more things to consider that we do not go into here. Note that this also applies to
/// passing/calling functions across language boundaries via function pointers.
///
/// **Nothing in this section should be taken as a guarantee for non-Rust-to-Rust calls, even with
/// types from `core::ffi` or `libc`**.
///
/// For two signatures to be considered *ABI-compatible*, they must use a compatible ABI string,
/// must take the same number of arguments, the individual argument types and the return types must
Expand Down

0 comments on commit e212260

Please sign in to comment.