Skip to content

Commit 032d810

Browse files
committed
Add a big notice about const intrinsics
1 parent 9ee16e1 commit 032d810

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/libcore/intrinsics.rs

+16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
//! Compiler intrinsics.
22
//!
33
//! The corresponding definitions are in `librustc_codegen_llvm/intrinsic.rs`.
4+
//! The corresponding const implementations are in `librustc_mir/interpret/intrinsics.rs`
5+
//!
6+
//! # Const intrinsics
7+
//!
8+
//! Note: any changes to the constness of intrinsics should be discussed with the language team.
9+
//! This includes changes in the stability of the constness.
10+
//!
11+
//! In order to make an intrinsic usable at compile-time, one needs to copy the implementation
12+
//! from https://github.com/rust-lang/miri/blob/master/src/shims/intrinsics.rs to
13+
//! `librustc_mir/interpret/intrinsics.rs` and add a
14+
//! `#[rustc_const_unstable(feature = "foo", issue = "01234")]` to the intrinsic.
15+
//!
16+
//! If an intrinsic is supposed to be used from a `const fn` with a `rustc_const_stable` attribute,
17+
//! the intrinsic's attribute must be `rustc_const_stable`, too. Such a change should not be done
18+
//! without T-lang consulation, because it bakes a feature into the language that cannot be
19+
//! replicated in user code without compiler support.
420
//!
521
//! # Volatiles
622
//!

0 commit comments

Comments
 (0)