about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2024-10-26 17:31:03 -0400
committerMark Rousskov <mark.simulacrum@gmail.com>2024-10-26 17:32:50 -0400
commitc1a08f97637671b4e8ef69f69ddb811c472acaf1 (patch)
treea6b97288f5390291fd8ae7156e230468b12a9830
parent4d88de2acd2cf8595c61e5c8d39183e5579204d8 (diff)
downloadrust-c1a08f97637671b4e8ef69f69ddb811c472acaf1.tar.gz
rust-c1a08f97637671b4e8ef69f69ddb811c472acaf1.zip
Make clearer that guarantees in ABI compatibility are for Rust only
-rw-r--r--library/core/src/primitive_docs.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/library/core/src/primitive_docs.rs b/library/core/src/primitive_docs.rs
index bf9bfd84b56..4a6fca5085c 100644
--- a/library/core/src/primitive_docs.rs
+++ b/library/core/src/primitive_docs.rs
@@ -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
@@ -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