Skip to content

Commit 1f20b4d

Browse files
committed
Explain the difference between the two whitelists
1 parent cc5b357 commit 1f20b4d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/librustc/ty/constness.rs

+9
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ impl<'tcx> TyCtxt<'tcx> {
4040
/// for being called from stable `const fn`s (`min_const_fn`).
4141
///
4242
/// Adding more intrinsics requires sign-off from @rust-lang/lang.
43+
///
44+
/// This list differs from the list in `is_const_intrinsic` in the sense that any item on this
45+
/// list must be on the `is_const_intrinsic` list, too, because if an intrinsic is callable from
46+
/// stable, it must be callable at all.
4347
fn is_intrinsic_min_const_fn(self, def_id: DefId) -> bool {
4448
match self.item_name(def_id) {
4549
| sym::size_of
@@ -108,6 +112,11 @@ pub fn provide(providers: &mut Providers<'_>) {
108112
match tcx.item_name(def_id) {
109113
// Keep this list in the same order as the match patterns in
110114
// `librustc_mir/interpret/intrinsics.rs`
115+
116+
// This whitelist is a list of intrinsics that have a miri-engine implementation
117+
// and can thus be called when enabling enough feature gates. The similar
118+
// whitelist in `is_intrinsic_min_const_fn` (in this file), exists for allowing
119+
// the intrinsics to be transitively called by stable const fns.
111120
| sym::caller_location
112121

113122
| sym::min_align_of

0 commit comments

Comments
 (0)