about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTobias <206408826+t5kd@users.noreply.github.com>2025-04-23 20:33:22 +0200
committerTobias <206408826+t5kd@users.noreply.github.com>2025-04-25 23:23:02 +0200
commit1862feb0e7b88487e17d999ee5d1eb97a0b27b6a (patch)
tree1f4dfd836d9bc6b7f2526283337e8bbc54fbf043
parente3e432d4d65a55e6db167598e96db2bcb163e316 (diff)
downloadrust-1862feb0e7b88487e17d999ee5d1eb97a0b27b6a.tar.gz
rust-1862feb0e7b88487e17d999ee5d1eb97a0b27b6a.zip
Update `extern` docs for Rust 2024 and add safety remarks
-rw-r--r--library/std/src/keyword_docs.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/library/std/src/keyword_docs.rs b/library/std/src/keyword_docs.rs
index c07c391892d..69c16f2eba4 100644
--- a/library/std/src/keyword_docs.rs
+++ b/library/std/src/keyword_docs.rs
@@ -381,11 +381,15 @@ mod enum_keyword {}
 /// lazy_static;`. The other use is in foreign function interfaces (FFI).
 ///
 /// `extern` is used in two different contexts within FFI. The first is in the form of external
-/// blocks, for declaring function interfaces that Rust code can call foreign code by.
+/// blocks, for declaring function interfaces that Rust code can call foreign code by. This use
+/// of `extern` is unsafe, since we are asserting to the compiler that all function declarations
+/// are correct. If they are not, using these items may lead to undefined behavior.
 ///
 /// ```rust ignore
+/// // SAFETY: The function declarations given below are in
+/// // line with the header files of `my_c_library`.
 /// #[link(name = "my_c_library")]
-/// extern "C" {
+/// unsafe extern "C" {
 ///     fn my_c_function(x: i32) -> bool;
 /// }
 /// ```