about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJubilee <workingjubilee@gmail.com>2025-06-13 20:59:18 -0700
committerGitHub <noreply@github.com>2025-06-13 20:59:18 -0700
commit2f5655741808cf4dd049984570a14d811f08fe29 (patch)
tree87e369053973498cdd94c78b28bfbd960c1cd206
parentfa359f66a17d46a5fa10782c5d9a385a1f60c4f2 (diff)
parent527f35a28f2661e40b1b6824103861312f3a188d (diff)
downloadrust-2f5655741808cf4dd049984570a14d811f08fe29.tar.gz
rust-2f5655741808cf4dd049984570a14d811f08fe29.zip
Rollup merge of #142439 - scrabsha:rust/sasha/uwkqrkztvqry, r=RalfJung
doc: mention that intrinsics should not be called in user code

Intrinsic functions declared in `std::intrinsics` are an implementation detail and should not be called directly by the user. The compiler explicitly warns against their use in user code:

```
warning: the feature `core_intrinsics` is internal to the compiler or standard library
 --> src/lib.rs:1:12
  |
1 | #![feature(core_intrinsics)]
  |            ^^^^^^^^^^^^^^^
  |
  = note: using it is strongly discouraged
  = note: `#[warn(internal_features)]` on by default
```

[**Playground link**]

This PR documents what the compiler warning says: these intrinsics should not be used in user code.

[**Playground link**]: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=1c893b0698291f550bbdde0151fd221b
-rw-r--r--library/core/src/intrinsics/mod.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs
index 7ba48cc7268..e0e80fc9b41 100644
--- a/library/core/src/intrinsics/mod.rs
+++ b/library/core/src/intrinsics/mod.rs
@@ -1,5 +1,9 @@
 //! Compiler intrinsics.
 //!
+//! The functions in this module are implementation details of `core` and should
+//! not be used outside of the standard library. We generally provide access to
+//! intrinsics via stable wrapper functions. Use these instead.
+//!
 //! These are the imports making intrinsics available to Rust code. The actual implementations live in the compiler.
 //! Some of these intrinsics are lowered to MIR in <https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_transform/src/lower_intrinsics.rs>.
 //! The remaining intrinsics are implemented for the LLVM backend in <https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs>