@@ -449,38 +449,38 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
449
449
destination : & Option < ( mir:: Place < ' tcx > , mir:: BasicBlock ) > ,
450
450
cleanup : Option < mir:: BasicBlock > ,
451
451
) -> bool {
452
- // Emit a panic or a no-op for `panic_if_uninhabited` .
452
+ // Emit a panic or a no-op for `assert_*` intrinsics .
453
453
// These are intrinsics that compile to panics so that we can get a message
454
454
// which mentions the offending type, even from a const context.
455
455
#[ derive( Debug , PartialEq ) ]
456
- enum PanicIntrinsic {
457
- IfUninhabited ,
458
- IfZeroInvalid ,
459
- IfAnyInvalid ,
456
+ enum AssertIntrinsic {
457
+ Inhabited ,
458
+ ZeroValid ,
459
+ UninitValid ,
460
460
} ;
461
461
let panic_intrinsic = intrinsic. and_then ( |i| match i {
462
462
// FIXME: Move to symbols instead of strings.
463
- "panic_if_uninhabited " => Some ( PanicIntrinsic :: IfUninhabited ) ,
464
- "panic_if_zero_invalid " => Some ( PanicIntrinsic :: IfZeroInvalid ) ,
465
- "panic_if_any_invalid " => Some ( PanicIntrinsic :: IfAnyInvalid ) ,
463
+ "assert_inhabited " => Some ( AssertIntrinsic :: Inhabited ) ,
464
+ "assert_zero_valid " => Some ( AssertIntrinsic :: ZeroValid ) ,
465
+ "assert_uninit_valid " => Some ( AssertIntrinsic :: UninitValid ) ,
466
466
_ => None ,
467
467
} ) ;
468
468
if let Some ( intrinsic) = panic_intrinsic {
469
- use PanicIntrinsic :: * ;
469
+ use AssertIntrinsic :: * ;
470
470
let ty = instance. unwrap ( ) . substs . type_at ( 0 ) ;
471
471
let layout = bx. layout_of ( ty) ;
472
472
let do_panic = match intrinsic {
473
- IfUninhabited => layout. abi . is_uninhabited ( ) ,
473
+ Inhabited => layout. abi . is_uninhabited ( ) ,
474
474
// We unwrap as the error type is `!`.
475
- IfZeroInvalid => !layout. might_permit_raw_init ( bx, /*zero:*/ true ) . unwrap ( ) ,
475
+ ZeroValid => !layout. might_permit_raw_init ( bx, /*zero:*/ true ) . unwrap ( ) ,
476
476
// We unwrap as the error type is `!`.
477
- IfAnyInvalid => !layout. might_permit_raw_init ( bx, /*zero:*/ false ) . unwrap ( ) ,
477
+ UninitValid => !layout. might_permit_raw_init ( bx, /*zero:*/ false ) . unwrap ( ) ,
478
478
} ;
479
479
if do_panic {
480
480
let msg_str = if layout. abi . is_uninhabited ( ) {
481
481
// Use this error even for the other intrinsics as it is more precise.
482
482
format ! ( "attempted to instantiate uninhabited type `{}`" , ty)
483
- } else if intrinsic == IfZeroInvalid {
483
+ } else if intrinsic == ZeroValid {
484
484
format ! ( "attempted to zero-initialize type `{}`, which is invalid" , ty)
485
485
} else {
486
486
format ! ( "attempted to leave type `{}` uninitialized, which is invalid" , ty)
0 commit comments