@@ -187,9 +187,9 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
187187 self . memory . write_f64 ( ptr, f) ?;
188188 Ok ( ptr)
189189 } ,
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" ) ,
193193 Integral ( ConstInt :: I8 ( i) ) => i2p ! ( i, 1 ) ,
194194 Integral ( ConstInt :: U8 ( i) ) => i2p ! ( i, 1 ) ,
195195 Integral ( ConstInt :: Isize ( ConstIsize :: Is16 ( i) ) ) |
@@ -359,7 +359,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
359359 use rustc:: ty:: layout:: Layout :: * ;
360360 let tup_layout = match * dest_layout {
361361 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" ) ,
363363 } ;
364364
365365 let overflowed = self . intrinsic_overflowing ( op, left, right, dest) ?;
@@ -446,8 +446,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
446446 Array { .. } => {
447447 let elem_size = match dest_ty. sty {
448448 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) ,
451450 } ;
452451 let offsets = ( 0 ..) . map ( |i| i * elem_size) ;
453452 self . assign_fields ( dest, offsets, operands) ?;
@@ -463,7 +462,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
463462 . map ( |s| s. bytes ( ) ) ;
464463 self . assign_fields ( dest, offsets, operands) ?;
465464 } else {
466- panic ! ( "tried to assign {:?} to Layout::General" , kind) ;
465+ bug ! ( "tried to assign {:?} to Layout::General" , kind) ;
467466 }
468467 }
469468
@@ -480,7 +479,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
480479 self . memory . write_isize ( dest, 0 ) ?;
481480 }
482481 } else {
483- panic ! ( "tried to assign {:?} to Layout::RawNullablePointer" , kind) ;
482+ bug ! ( "tried to assign {:?} to Layout::RawNullablePointer" , kind) ;
484483 }
485484 }
486485
@@ -497,7 +496,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
497496 try!( self . memory . write_isize ( dest, 0 ) ) ;
498497 }
499498 } else {
500- panic ! ( "tried to assign {:?} to Layout::RawNullablePointer" , kind) ;
499+ bug ! ( "tried to assign {:?} to Layout::RawNullablePointer" , kind) ;
501500 }
502501 }
503502
@@ -513,7 +512,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
513512 self . memory . write_uint ( dest, val, size) ?;
514513 }
515514 } else {
516- panic ! ( "tried to assign {:?} to Layout::CEnum" , kind) ;
515+ bug ! ( "tried to assign {:?} to Layout::CEnum" , kind) ;
517516 }
518517 }
519518
@@ -524,7 +523,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
524523 Repeat ( ref operand, _) => {
525524 let ( elem_size, elem_align, length) = match dest_ty. sty {
526525 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) ,
528527 } ;
529528
530529 let src = self . eval_operand ( operand) ?;
@@ -542,9 +541,9 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
542541 ty:: TySlice ( _) => if let LvalueExtra :: Length ( n) = src. extra {
543542 n
544543 } 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) ;
546545 } ,
547- _ => panic ! ( "Rvalue::Len expected array or slice, got {:?}" , ty) ,
546+ _ => bug ! ( "Rvalue::Len expected array or slice, got {:?}" , ty) ,
548547 } ;
549548 self . memory . write_usize ( dest, len) ?;
550549 }
@@ -559,7 +558,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
559558 self . memory . write_usize ( len_ptr, len) ?;
560559 }
561560 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" ) ,
563562 }
564563 }
565564
@@ -615,7 +614,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
615614 let fn_ptr = self . memory . create_fn_ptr ( def_id, substs, fn_ty) ;
616615 self . memory . write_ptr ( dest, fn_ptr) ?;
617616 } ,
618- ref other => panic ! ( "reify fn pointer on {:?}" , other) ,
617+ ref other => bug ! ( "reify fn pointer on {:?}" , other) ,
619618 } ,
620619
621620 UnsafeFnPointer => match dest_ty. sty {
@@ -626,7 +625,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
626625 let fn_ptr = self . memory . create_fn_ptr ( fn_def. def_id , fn_def. substs , unsafe_fn_ty) ;
627626 self . memory . write_ptr ( dest, fn_ptr) ?;
628627 } ,
629- ref other => panic ! ( "fn to unsafe fn cast on {:?}" , other) ,
628+ ref other => bug ! ( "fn to unsafe fn cast on {:?}" , other) ,
630629 } ,
631630 }
632631 }
@@ -649,10 +648,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
649648 let field = & variant. fields [ index] ;
650649 field. ty ( self . tcx , substs)
651650 }
652- _ => panic ! (
653- "non-enum for StructWrappedNullablePointer: {}" ,
654- ty,
655- ) ,
651+ _ => bug ! ( "non-enum for StructWrappedNullablePointer: {}" , ty) ,
656652 } ;
657653
658654 self . field_path_offset ( inner_ty, path)
@@ -772,15 +768,15 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
772768 if let LvalueExtra :: DowncastVariant ( variant_idx) = base. extra {
773769 & variants[ variant_idx]
774770 } else {
775- panic ! ( "field access on enum had no variant index" ) ;
771+ bug ! ( "field access on enum had no variant index" ) ;
776772 }
777773 }
778774 RawNullablePointer { .. } => {
779775 assert_eq ! ( field. index( ) , 0 ) ;
780776 return Ok ( base) ;
781777 }
782778 StructWrappedNullablePointer { ref nonnull, .. } => nonnull,
783- _ => panic ! ( "field access on non-product type: {:?}" , base_layout) ,
779+ _ => bug ! ( "field access on non-product type: {:?}" , base_layout) ,
784780 } ;
785781
786782 let offset = variant. field_offset ( field. index ( ) ) . bytes ( ) ;
@@ -799,7 +795,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
799795 RawNullablePointer { .. } | StructWrappedNullablePointer { .. } => {
800796 return Ok ( base) ;
801797 }
802- _ => panic ! ( "variant downcast on non-aggregate: {:?}" , base_layout) ,
798+ _ => bug ! ( "variant downcast on non-aggregate: {:?}" , base_layout) ,
803799 }
804800 } ,
805801
@@ -822,7 +818,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
822818 let elem_size = match base_ty. sty {
823819 ty:: TyArray ( elem_ty, _) |
824820 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) ,
826822 } ;
827823 let n_ptr = self . eval_operand ( operand) ?;
828824 let n = self . memory . read_usize ( n_ptr) ?;
@@ -901,7 +897,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
901897 }
902898 }
903899
904- _ => panic ! ( "primitive read of non-primitive type: {:?}" , ty) ,
900+ _ => bug ! ( "primitive read of non-primitive type: {:?}" , ty) ,
905901 } ;
906902 Ok ( val)
907903 }
0 commit comments