@@ -2,7 +2,6 @@ use rustc::hir::def_id::DefId;
2
2
use rustc:: hir;
3
3
use rustc:: mir:: * ;
4
4
use rustc:: ty:: { self , Predicate , Ty , TyCtxt , adjustment:: { PointerCast } } ;
5
- use rustc_target:: spec:: abi;
6
5
use std:: borrow:: Cow ;
7
6
use syntax_pos:: Span ;
8
7
use syntax:: symbol:: { sym, Symbol } ;
@@ -356,33 +355,16 @@ fn check_terminator(
356
355
} => {
357
356
let fn_ty = func. ty ( body, tcx) ;
358
357
if let ty:: FnDef ( def_id, _) = fn_ty. kind {
359
-
360
- // some intrinsics are waved through if called inside the
361
- // standard library. Users never need to call them directly
362
- match tcx. fn_sig ( def_id) . abi ( ) {
363
- abi:: Abi :: RustIntrinsic => if !is_intrinsic_whitelisted ( tcx, def_id) {
364
- return Err ( (
365
- span,
366
- "can only call a curated list of intrinsics in `min_const_fn`" . into ( ) ,
367
- ) )
368
- } ,
369
- abi:: Abi :: Rust if tcx. is_min_const_fn ( def_id) => { } ,
370
- abi:: Abi :: Rust => return Err ( (
358
+ if !tcx. is_min_const_fn ( def_id) {
359
+ return Err ( (
371
360
span,
372
361
format ! (
373
362
"can only call other `const fn` within a `const fn`, \
374
363
but `{:?}` is not stable as `const fn`",
375
364
func,
376
365
)
377
366
. into ( ) ,
378
- ) ) ,
379
- abi => return Err ( (
380
- span,
381
- format ! (
382
- "cannot call functions with `{}` abi in `min_const_fn`" ,
383
- abi,
384
- ) . into ( ) ,
385
- ) ) ,
367
+ ) ) ;
386
368
}
387
369
388
370
check_operand ( tcx, func, span, def_id, body) ?;
@@ -410,34 +392,3 @@ fn check_terminator(
410
392
}
411
393
}
412
394
413
- /// Returns `true` if the `def_id` refers to an intrisic which we've whitelisted
414
- /// for being called from stable `const fn`s (`min_const_fn`).
415
- ///
416
- /// Adding more intrinsics requires sign-off from @rust-lang/lang.
417
- fn is_intrinsic_whitelisted ( tcx : TyCtxt < ' tcx > , def_id : DefId ) -> bool {
418
- match tcx. item_name ( def_id) {
419
- | sym:: size_of
420
- | sym:: min_align_of
421
- | sym:: needs_drop
422
- // Arithmetic:
423
- | sym:: add_with_overflow // ~> .overflowing_add
424
- | sym:: sub_with_overflow // ~> .overflowing_sub
425
- | sym:: mul_with_overflow // ~> .overflowing_mul
426
- | sym:: wrapping_add // ~> .wrapping_add
427
- | sym:: wrapping_sub // ~> .wrapping_sub
428
- | sym:: wrapping_mul // ~> .wrapping_mul
429
- | sym:: saturating_add // ~> .saturating_add
430
- | sym:: saturating_sub // ~> .saturating_sub
431
- | sym:: unchecked_shl // ~> .wrapping_shl
432
- | sym:: unchecked_shr // ~> .wrapping_shr
433
- | sym:: rotate_left // ~> .rotate_left
434
- | sym:: rotate_right // ~> .rotate_right
435
- | sym:: ctpop // ~> .count_ones
436
- | sym:: ctlz // ~> .leading_zeros
437
- | sym:: cttz // ~> .trailing_zeros
438
- | sym:: bswap // ~> .swap_bytes
439
- | sym:: bitreverse // ~> .reverse_bits
440
- => true ,
441
- _ => false ,
442
- }
443
- }
0 commit comments