@@ -14,6 +14,7 @@ use stable_mir::{
14
14
#[ derive( Clone , Debug ) ]
15
15
pub enum Intrinsic {
16
16
AddWithOverflow ,
17
+ AlignOfVal ,
17
18
ArithOffset ,
18
19
AssertInhabited ,
19
20
AssertMemUninitializedValid ,
@@ -81,12 +82,9 @@ pub enum Intrinsic {
81
82
LogF64 ,
82
83
MaxNumF32 ,
83
84
MaxNumF64 ,
84
- MinAlignOf ,
85
- MinAlignOfVal ,
86
85
MinNumF32 ,
87
86
MinNumF64 ,
88
87
MulWithOverflow ,
89
- NeedsDrop ,
90
88
PowF32 ,
91
89
PowF64 ,
92
90
PowIF32 ,
@@ -132,8 +130,6 @@ pub enum Intrinsic {
132
130
Transmute ,
133
131
TruncF32 ,
134
132
TruncF64 ,
135
- TypeId ,
136
- TypeName ,
137
133
TypedSwap ,
138
134
UnalignedVolatileLoad ,
139
135
UncheckedDiv ,
@@ -181,6 +177,13 @@ impl Intrinsic {
181
177
assert_sig_matches ! ( sig, _, _ => RigidTy :: Tuple ( _) ) ;
182
178
Self :: AddWithOverflow
183
179
}
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
+ }
184
187
"arith_offset" => {
185
188
assert_sig_matches ! ( sig,
186
189
RigidTy :: RawPtr ( _, Mutability :: Not ) ,
@@ -309,22 +312,14 @@ impl Intrinsic {
309
312
assert_sig_matches ! ( sig, RigidTy :: Bool => RigidTy :: Bool ) ;
310
313
Self :: Likely
311
314
}
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
- }
320
315
"mul_with_overflow" => {
321
316
assert_sig_matches ! ( sig, _, _ => RigidTy :: Tuple ( _) ) ;
322
317
Self :: MulWithOverflow
323
318
}
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
+ ) ,
328
323
// As of https://github.com/rust-lang/rust/pull/110822 the `offset` intrinsic is lowered to `mir::BinOp::Offset`
329
324
"offset" => unreachable ! (
330
325
"Expected `core::intrinsics::unreachable` to be handled by `BinOp::OffSet`"
@@ -361,7 +356,9 @@ impl Intrinsic {
361
356
assert_sig_matches ! ( sig, _, _ => _) ;
362
357
Self :: SaturatingSub
363
358
}
364
- "size_of" => unreachable ! ( ) ,
359
+ "size_of" => {
360
+ unreachable ! ( "Expected `core::intrinsics::size_of` to be handled by NullOp::SizeOf" )
361
+ }
365
362
"size_of_val" => {
366
363
assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Not ) => RigidTy :: Uint ( UintTy :: Usize ) ) ;
367
364
Self :: SizeOfVal
@@ -374,14 +371,12 @@ impl Intrinsic {
374
371
assert_sig_matches ! ( sig, _ => _) ;
375
372
Self :: Transmute
376
373
}
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
+ ) ,
385
380
"typed_swap_nonoverlapping" => {
386
381
assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , RigidTy :: RawPtr ( _, Mutability :: Mut ) => RigidTy :: Tuple ( _) ) ;
387
382
Self :: TypedSwap
@@ -409,6 +404,9 @@ impl Intrinsic {
409
404
"unreachable" => unreachable ! (
410
405
"Expected `std::intrinsics::unreachable` to be handled by `TerminatorKind::Unreachable`"
411
406
) ,
407
+ "variant_count" => unreachable ! (
408
+ "Expected nullary intrinsic `core::intrinsics::variant_count` to be const-evaluated before codegen"
409
+ ) ,
412
410
"volatile_copy_memory" => {
413
411
assert_sig_matches ! ( sig, RigidTy :: RawPtr ( _, Mutability :: Mut ) , RigidTy :: RawPtr ( _, Mutability :: Not ) , RigidTy :: Uint ( UintTy :: Usize ) => RigidTy :: Tuple ( _) ) ;
414
412
Self :: VolatileCopyMemory
0 commit comments