@@ -251,6 +251,30 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
251
251
}
252
252
} ;
253
253
254
+ // ABI check
255
+ {
256
+ let callee_abi = {
257
+ let instance_ty = instance. ty ( * self . tcx ) ;
258
+ match instance_ty. kind {
259
+ ty:: FnDef ( ..) =>
260
+ instance_ty. fn_sig ( * self . tcx ) . abi ( ) ,
261
+ ty:: Closure ( ..) => Abi :: RustCall ,
262
+ ty:: Generator ( ..) => Abi :: Rust ,
263
+ _ => bug ! ( "unexpected callee ty: {:?}" , instance_ty) ,
264
+ }
265
+ } ;
266
+ let normalize_abi = |abi| match abi {
267
+ Abi :: Rust | Abi :: RustCall | Abi :: RustIntrinsic | Abi :: PlatformIntrinsic =>
268
+ // These are all the same ABI, really.
269
+ Abi :: Rust ,
270
+ abi =>
271
+ abi,
272
+ } ;
273
+ if normalize_abi ( caller_abi) != normalize_abi ( callee_abi) {
274
+ throw_unsup ! ( FunctionAbiMismatch ( caller_abi, callee_abi) )
275
+ }
276
+ }
277
+
254
278
match instance. def {
255
279
ty:: InstanceDef :: Intrinsic ( ..) => {
256
280
assert ! ( caller_abi == Abi :: RustIntrinsic || caller_abi == Abi :: PlatformIntrinsic ) ;
@@ -263,30 +287,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
263
287
ty:: InstanceDef :: DropGlue ( ..) |
264
288
ty:: InstanceDef :: CloneShim ( ..) |
265
289
ty:: InstanceDef :: Item ( _) => {
266
- // ABI check
267
- {
268
- let callee_abi = {
269
- let instance_ty = instance. ty ( * self . tcx ) ;
270
- match instance_ty. kind {
271
- ty:: FnDef ( ..) =>
272
- instance_ty. fn_sig ( * self . tcx ) . abi ( ) ,
273
- ty:: Closure ( ..) => Abi :: RustCall ,
274
- ty:: Generator ( ..) => Abi :: Rust ,
275
- _ => bug ! ( "unexpected callee ty: {:?}" , instance_ty) ,
276
- }
277
- } ;
278
- let normalize_abi = |abi| match abi {
279
- Abi :: Rust | Abi :: RustCall | Abi :: RustIntrinsic | Abi :: PlatformIntrinsic =>
280
- // These are all the same ABI, really.
281
- Abi :: Rust ,
282
- abi =>
283
- abi,
284
- } ;
285
- if normalize_abi ( caller_abi) != normalize_abi ( callee_abi) {
286
- throw_unsup ! ( FunctionAbiMismatch ( caller_abi, callee_abi) )
287
- }
288
- }
289
-
290
290
// We need MIR for this fn
291
291
let body = match M :: find_fn ( self , instance, args, dest, ret, unwind) ? {
292
292
Some ( body) => body,
0 commit comments