@@ -187,9 +187,9 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
187
187
self . memory . write_f64 ( ptr, f) ?;
188
188
Ok ( ptr)
189
189
} ,
190
- Float ( ConstFloat :: FInfer { ..} ) => unreachable ! ( ) ,
191
- Integral ( ConstInt :: Infer ( _) ) => unreachable ! ( ) ,
192
- Integral ( ConstInt :: InferSigned ( _) ) => unreachable ! ( ) ,
190
+ Float ( ConstFloat :: FInfer { ..} ) |
191
+ Integral ( ConstInt :: Infer ( _) ) |
192
+ Integral ( ConstInt :: InferSigned ( _) ) => bug ! ( "uninferred constants only exist before typeck" ) ,
193
193
Integral ( ConstInt :: I8 ( i) ) => i2p ! ( i, 1 ) ,
194
194
Integral ( ConstInt :: U8 ( i) ) => i2p ! ( i, 1 ) ,
195
195
Integral ( ConstInt :: Isize ( ConstIsize :: Is16 ( i) ) ) |
@@ -359,7 +359,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
359
359
use rustc:: ty:: layout:: Layout :: * ;
360
360
let tup_layout = match * dest_layout {
361
361
Univariant { ref variant, .. } => variant,
362
- _ => panic ! ( "checked bin op returns something other than a tuple" ) ,
362
+ _ => bug ! ( "checked bin op returns something other than a tuple" ) ,
363
363
} ;
364
364
365
365
let overflowed = self . intrinsic_overflowing ( op, left, right, dest) ?;
@@ -446,8 +446,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
446
446
Array { .. } => {
447
447
let elem_size = match dest_ty. sty {
448
448
ty:: TyArray ( elem_ty, _) => self . type_size ( elem_ty) as u64 ,
449
- _ => panic ! ( "tried to assign {:?} to non-array type {:?}" ,
450
- kind, dest_ty) ,
449
+ _ => bug ! ( "tried to assign {:?} to non-array type {:?}" , kind, dest_ty) ,
451
450
} ;
452
451
let offsets = ( 0 ..) . map ( |i| i * elem_size) ;
453
452
self . assign_fields ( dest, offsets, operands) ?;
@@ -463,7 +462,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
463
462
. map ( |s| s. bytes ( ) ) ;
464
463
self . assign_fields ( dest, offsets, operands) ?;
465
464
} else {
466
- panic ! ( "tried to assign {:?} to Layout::General" , kind) ;
465
+ bug ! ( "tried to assign {:?} to Layout::General" , kind) ;
467
466
}
468
467
}
469
468
@@ -480,7 +479,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
480
479
self . memory . write_isize ( dest, 0 ) ?;
481
480
}
482
481
} else {
483
- panic ! ( "tried to assign {:?} to Layout::RawNullablePointer" , kind) ;
482
+ bug ! ( "tried to assign {:?} to Layout::RawNullablePointer" , kind) ;
484
483
}
485
484
}
486
485
@@ -497,7 +496,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
497
496
try!( self . memory . write_isize ( dest, 0 ) ) ;
498
497
}
499
498
} else {
500
- panic ! ( "tried to assign {:?} to Layout::RawNullablePointer" , kind) ;
499
+ bug ! ( "tried to assign {:?} to Layout::RawNullablePointer" , kind) ;
501
500
}
502
501
}
503
502
@@ -513,7 +512,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
513
512
self . memory . write_uint ( dest, val, size) ?;
514
513
}
515
514
} else {
516
- panic ! ( "tried to assign {:?} to Layout::CEnum" , kind) ;
515
+ bug ! ( "tried to assign {:?} to Layout::CEnum" , kind) ;
517
516
}
518
517
}
519
518
@@ -524,7 +523,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
524
523
Repeat ( ref operand, _) => {
525
524
let ( elem_size, elem_align, length) = match dest_ty. sty {
526
525
ty:: TyArray ( elem_ty, n) => ( self . type_size ( elem_ty) , self . type_align ( elem_ty) , n) ,
527
- _ => panic ! ( "tried to assign array-repeat to non-array type {:?}" , dest_ty) ,
526
+ _ => bug ! ( "tried to assign array-repeat to non-array type {:?}" , dest_ty) ,
528
527
} ;
529
528
530
529
let src = self . eval_operand ( operand) ?;
@@ -542,9 +541,9 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
542
541
ty:: TySlice ( _) => if let LvalueExtra :: Length ( n) = src. extra {
543
542
n
544
543
} else {
545
- panic ! ( "Rvalue::Len of a slice given non-slice pointer: {:?}" , src) ;
544
+ bug ! ( "Rvalue::Len of a slice given non-slice pointer: {:?}" , src) ;
546
545
} ,
547
- _ => panic ! ( "Rvalue::Len expected array or slice, got {:?}" , ty) ,
546
+ _ => bug ! ( "Rvalue::Len expected array or slice, got {:?}" , ty) ,
548
547
} ;
549
548
self . memory . write_usize ( dest, len) ?;
550
549
}
@@ -559,7 +558,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
559
558
self . memory . write_usize ( len_ptr, len) ?;
560
559
}
561
560
LvalueExtra :: DowncastVariant ( ..) =>
562
- panic ! ( "attempted to take a reference to an enum downcast lvalue" ) ,
561
+ bug ! ( "attempted to take a reference to an enum downcast lvalue" ) ,
563
562
}
564
563
}
565
564
@@ -615,7 +614,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
615
614
let fn_ptr = self . memory . create_fn_ptr ( def_id, substs, fn_ty) ;
616
615
self . memory . write_ptr ( dest, fn_ptr) ?;
617
616
} ,
618
- ref other => panic ! ( "reify fn pointer on {:?}" , other) ,
617
+ ref other => bug ! ( "reify fn pointer on {:?}" , other) ,
619
618
} ,
620
619
621
620
UnsafeFnPointer => match dest_ty. sty {
@@ -626,7 +625,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
626
625
let fn_ptr = self . memory . create_fn_ptr ( fn_def. def_id , fn_def. substs , unsafe_fn_ty) ;
627
626
self . memory . write_ptr ( dest, fn_ptr) ?;
628
627
} ,
629
- ref other => panic ! ( "fn to unsafe fn cast on {:?}" , other) ,
628
+ ref other => bug ! ( "fn to unsafe fn cast on {:?}" , other) ,
630
629
} ,
631
630
}
632
631
}
@@ -649,10 +648,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
649
648
let field = & variant. fields [ index] ;
650
649
field. ty ( self . tcx , substs)
651
650
}
652
- _ => panic ! (
653
- "non-enum for StructWrappedNullablePointer: {}" ,
654
- ty,
655
- ) ,
651
+ _ => bug ! ( "non-enum for StructWrappedNullablePointer: {}" , ty) ,
656
652
} ;
657
653
658
654
self . field_path_offset ( inner_ty, path)
@@ -772,15 +768,15 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
772
768
if let LvalueExtra :: DowncastVariant ( variant_idx) = base. extra {
773
769
& variants[ variant_idx]
774
770
} else {
775
- panic ! ( "field access on enum had no variant index" ) ;
771
+ bug ! ( "field access on enum had no variant index" ) ;
776
772
}
777
773
}
778
774
RawNullablePointer { .. } => {
779
775
assert_eq ! ( field. index( ) , 0 ) ;
780
776
return Ok ( base) ;
781
777
}
782
778
StructWrappedNullablePointer { ref nonnull, .. } => nonnull,
783
- _ => panic ! ( "field access on non-product type: {:?}" , base_layout) ,
779
+ _ => bug ! ( "field access on non-product type: {:?}" , base_layout) ,
784
780
} ;
785
781
786
782
let offset = variant. field_offset ( field. index ( ) ) . bytes ( ) ;
@@ -799,7 +795,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
799
795
RawNullablePointer { .. } | StructWrappedNullablePointer { .. } => {
800
796
return Ok ( base) ;
801
797
}
802
- _ => panic ! ( "variant downcast on non-aggregate: {:?}" , base_layout) ,
798
+ _ => bug ! ( "variant downcast on non-aggregate: {:?}" , base_layout) ,
803
799
}
804
800
} ,
805
801
@@ -822,7 +818,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
822
818
let elem_size = match base_ty. sty {
823
819
ty:: TyArray ( elem_ty, _) |
824
820
ty:: TySlice ( elem_ty) => self . type_size ( elem_ty) ,
825
- _ => panic ! ( "indexing expected an array or slice, got {:?}" , base_ty) ,
821
+ _ => bug ! ( "indexing expected an array or slice, got {:?}" , base_ty) ,
826
822
} ;
827
823
let n_ptr = self . eval_operand ( operand) ?;
828
824
let n = self . memory . read_usize ( n_ptr) ?;
@@ -901,7 +897,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
901
897
}
902
898
}
903
899
904
- _ => panic ! ( "primitive read of non-primitive type: {:?}" , ty) ,
900
+ _ => bug ! ( "primitive read of non-primitive type: {:?}" , ty) ,
905
901
} ;
906
902
Ok ( val)
907
903
}
0 commit comments