Skip to content

Commit 122d465

Browse files
committed
Specifically whitelist intrinsics that are promotable
1 parent ac5e4f9 commit 122d465

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/librustc_mir/transform/qualify_consts.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -919,9 +919,17 @@ This does not pose a problem by itself because they can't be accessed directly."
919919
Abi::PlatformIntrinsic => {
920920
assert!(!self.tcx.is_const_fn(def_id));
921921
match &self.tcx.item_name(def_id).as_str()[..] {
922+
// Do not add anything to this list without consulting
923+
// @eddyb, @oli-obk and @nikomatsakis
922924
| "size_of"
923925
| "min_align_of"
924-
| "type_id"
926+
| "type_id" => {
927+
is_const_fn = Some(def_id);
928+
promotable = true;
929+
},
930+
// When adding something to this list, make sure to also implement
931+
// the corresponding entry in the `call_intrinsic` method in
932+
// rustc_mir::interpret::const_eval
925933
| "bswap"
926934
| "ctpop"
927935
| "cttz"
@@ -935,9 +943,6 @@ This does not pose a problem by itself because they can't be accessed directly."
935943

936944
_ => {}
937945
}
938-
// we can always mark intrinsics as promotable as they are inherently
939-
// unstable
940-
promotable = true;
941946
}
942947
_ => {
943948
if self.tcx.is_const_fn(def_id) {

0 commit comments

Comments
 (0)