Skip to content

Commit 527f35a

Browse files
committed
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 called outside the standard library. [**Playground link**]: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=1c893b0698291f550bbdde0151fd221b
1 parent 6c8138d commit 527f35a

File tree

1 file changed

+4
-0
lines changed
  • library/core/src/intrinsics

1 file changed

+4
-0
lines changed

library/core/src/intrinsics/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
//! Compiler intrinsics.
22
//!
3+
//! The functions in this module are implementation details of `core` and should
4+
//! not be used outside of the standard library. We generally provide access to
5+
//! intrinsics via stable wrapper functions. Use these instead.
6+
//!
37
//! These are the imports making intrinsics available to Rust code. The actual implementations live in the compiler.
48
//! 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>.
59
//! 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>

0 commit comments

Comments
 (0)