@@ -14,6 +14,7 @@ use stable_mir::{
1414#[ derive( Clone , Debug ) ]
1515pub enum Intrinsic {
1616 AddWithOverflow ,
17+ AlignOfVal ,
1718 ArithOffset ,
1819 AssertInhabited ,
1920 AssertMemUninitializedValid ,
@@ -81,12 +82,9 @@ pub enum Intrinsic {
8182 LogF64 ,
8283 MaxNumF32 ,
8384 MaxNumF64 ,
84- MinAlignOf ,
85- MinAlignOfVal ,
8685 MinNumF32 ,
8786 MinNumF64 ,
8887 MulWithOverflow ,
89- NeedsDrop ,
9088 PowF32 ,
9189 PowF64 ,
9290 PowIF32 ,
@@ -132,8 +130,6 @@ pub enum Intrinsic {
132130 Transmute ,
133131 TruncF32 ,
134132 TruncF64 ,
135- TypeId ,
136- TypeName ,
137133 TypedSwap ,
138134 UnalignedVolatileLoad ,
139135 UncheckedDiv ,
@@ -181,6 +177,13 @@ impl Intrinsic {
181177 assert_sig_matches ! ( sig, _, _ => RigidTy :: Tuple ( _) ) ;
182178 Self :: AddWithOverflow
183179 }
180+ "align_of" => unreachable ! (
181+ "Expected `core::intrinsics::align_of` to be handled by NullOp::SizeOf"
182+ ) ,
183+ "align_of_val" => {
184+ assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Not ) => RigidTy :: Uint ( UintTy :: Usize ) ) ;
185+ Self :: AlignOfVal
186+ }
184187 "arith_offset" => {
185188 assert_sig_matches ! ( sig,
186189 RigidTy :: RawPtr ( _, Mutability :: Not ) ,
@@ -309,22 +312,14 @@ impl Intrinsic {
309312 assert_sig_matches ! ( sig, RigidTy :: Bool => RigidTy :: Bool ) ;
310313 Self :: Likely
311314 }
312- "align_of" => {
313- assert_sig_matches ! ( sig, => RigidTy :: Uint ( UintTy :: Usize ) ) ;
314- Self :: MinAlignOf
315- }
316- "align_of_val" => {
317- assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Not ) => RigidTy :: Uint ( UintTy :: Usize ) ) ;
318- Self :: MinAlignOfVal
319- }
320315 "mul_with_overflow" => {
321316 assert_sig_matches ! ( sig, _, _ => RigidTy :: Tuple ( _) ) ;
322317 Self :: MulWithOverflow
323318 }
324- "needs_drop" => {
325- assert_sig_matches ! ( sig , => RigidTy :: Bool ) ;
326- Self :: NeedsDrop
327- }
319+ // For const eval of nullary intrinsics, see https://github.com/rust-lang/rust/pull/142839
320+ "needs_drop" => unreachable ! (
321+ "Expected nullary intrinsic `core::intrinsics::type_id` to be const-evaluated before codegen"
322+ ) ,
328323 // As of https://github.com/rust-lang/rust/pull/110822 the `offset` intrinsic is lowered to `mir::BinOp::Offset`
329324 "offset" => unreachable ! (
330325 "Expected `core::intrinsics::unreachable` to be handled by `BinOp::OffSet`"
@@ -361,7 +356,9 @@ impl Intrinsic {
361356 assert_sig_matches ! ( sig, _, _ => _) ;
362357 Self :: SaturatingSub
363358 }
364- "size_of" => unreachable ! ( ) ,
359+ "size_of" => {
360+ unreachable ! ( "Expected `core::intrinsics::size_of` to be handled by NullOp::SizeOf" )
361+ }
365362 "size_of_val" => {
366363 assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Not ) => RigidTy :: Uint ( UintTy :: Usize ) ) ;
367364 Self :: SizeOfVal
@@ -374,14 +371,12 @@ impl Intrinsic {
374371 assert_sig_matches ! ( sig, _ => _) ;
375372 Self :: Transmute
376373 }
377- "type_id" => {
378- assert_sig_matches ! ( sig, => RigidTy :: Uint ( UintTy :: U128 ) ) ;
379- Self :: TypeId
380- }
381- "type_name" => {
382- assert_sig_matches ! ( sig, => RigidTy :: Ref ( _, _, Mutability :: Not ) ) ;
383- Self :: TypeName
384- }
374+ "type_id" => unreachable ! (
375+ "Expected nullary intrinsic `core::intrinsics::type_id` to be const-evaluated before codegen"
376+ ) ,
377+ "type_name" => unreachable ! (
378+ "Expected nullary intrinsic `core::intrinsics::type_name` to be const-evaluated before codegen"
379+ ) ,
385380 "typed_swap_nonoverlapping" => {
386381 assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , RigidTy :: RawPtr ( _, Mutability :: Mut ) => RigidTy :: Tuple ( _) ) ;
387382 Self :: TypedSwap
@@ -409,6 +404,9 @@ impl Intrinsic {
409404 "unreachable" => unreachable ! (
410405 "Expected `std::intrinsics::unreachable` to be handled by `TerminatorKind::Unreachable`"
411406 ) ,
407+ "variant_count" => unreachable ! (
408+ "Expected nullary intrinsic `core::intrinsics::variant_count` to be const-evaluated before codegen"
409+ ) ,
412410 "volatile_copy_memory" => {
413411 assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , RigidTy :: RawPtr ( _, Mutability :: Not ) , RigidTy :: Uint ( UintTy :: Usize ) => RigidTy :: Tuple ( _) ) ;
414412 Self :: VolatileCopyMemory
0 commit comments