@@ -7,8 +7,8 @@ use syntax::source_map::Span;
77use rustc_target:: spec:: abi:: Abi ;
88
99use super :: {
10- GlobalId , InterpResult , PointerArithmetic ,
11- InterpCx , Machine , OpTy , ImmTy , PlaceTy , MPlaceTy , StackPopCleanup , FnVal ,
10+ GlobalId , InterpResult , InterpCx , Machine ,
11+ OpTy , ImmTy , PlaceTy , MPlaceTy , StackPopCleanup , FnVal ,
1212} ;
1313
1414impl < ' mir , ' tcx , M : Machine < ' mir , ' tcx > > InterpCx < ' mir , ' tcx , M > {
@@ -115,40 +115,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
115115 expected,
116116 ref msg,
117117 target,
118- ..
118+ cleanup ,
119119 } => {
120120 let cond_val = self . read_immediate ( self . eval_operand ( cond, None ) ?) ?
121121 . to_scalar ( ) ?. to_bool ( ) ?;
122122 if expected == cond_val {
123123 self . go_to_block ( target) ;
124124 } else {
125- // Compute error message
126- use rustc:: mir:: interpret:: PanicInfo :: * ;
127- return Err ( match msg {
128- BoundsCheck { ref len, ref index } => {
129- let len = self
130- . read_immediate ( self . eval_operand ( len, None ) ?)
131- . expect ( "can't eval len" )
132- . to_scalar ( ) ?
133- . to_bits ( self . memory . pointer_size ( ) ) ? as u64 ;
134- let index = self
135- . read_immediate ( self . eval_operand ( index, None ) ?)
136- . expect ( "can't eval index" )
137- . to_scalar ( ) ?
138- . to_bits ( self . memory . pointer_size ( ) ) ? as u64 ;
139- err_panic ! ( BoundsCheck { len, index } )
140- }
141- Overflow ( op) => err_panic ! ( Overflow ( * op) ) ,
142- OverflowNeg => err_panic ! ( OverflowNeg ) ,
143- DivisionByZero => err_panic ! ( DivisionByZero ) ,
144- RemainderByZero => err_panic ! ( RemainderByZero ) ,
145- ResumedAfterReturn ( generator_kind)
146- => err_panic ! ( ResumedAfterReturn ( * generator_kind) ) ,
147- ResumedAfterPanic ( generator_kind)
148- => err_panic ! ( ResumedAfterPanic ( * generator_kind) ) ,
149- Panic { .. } => bug ! ( "`Panic` variant cannot occur in MIR" ) ,
150- }
151- . into ( ) ) ;
125+ M :: assert_panic ( self , msg, cleanup) ?;
152126 }
153127 }
154128
@@ -164,15 +138,21 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
164138 return Ok ( ( ) )
165139 } ,
166140
141+ // It is UB to ever encounter this.
142+ Unreachable => throw_ub ! ( Unreachable ) ,
143+
144+ // These should never occur for MIR we actually run.
145+ DropAndReplace { .. } |
146+ FalseEdges { .. } |
147+ FalseUnwind { .. } =>
148+ bug ! ( "{:#?} should have been eliminated by MIR pass" , terminator. kind) ,
149+
150+ // These are not (yet) supported. It is unclear if they even can occur in
151+ // MIR that we actually run.
167152 Yield { .. } |
168153 GeneratorDrop |
169- DropAndReplace { .. } |
170- Abort => unimplemented ! ( "{:#?}" , terminator. kind) ,
171- FalseEdges { .. } => bug ! ( "should have been eliminated by\
172- `simplify_branches` mir pass") ,
173- FalseUnwind { .. } => bug ! ( "should have been eliminated by\
174- `simplify_branches` mir pass") ,
175- Unreachable => throw_ub ! ( Unreachable ) ,
154+ Abort =>
155+ throw_unsup_format ! ( "Unsupported terminator kind: {:#?}" , terminator. kind) ,
176156 }
177157
178158 Ok ( ( ) )
0 commit comments