about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2019-11-25 16:25:10 +0100
committerRalf Jung <post@ralfj.de>2019-11-25 16:25:45 +0100
commit419d3fcf5466c5b02e77bcc736e0ff925e9a8a59 (patch)
treea6f97a1e5226f8d36eb0db3fb852ca294ca8972c
parent5900b32ceee5cbb7f7db11d9aed52a35ba3ec9be (diff)
downloadrust-419d3fcf5466c5b02e77bcc736e0ff925e9a8a59.tar.gz
rust-419d3fcf5466c5b02e77bcc736e0ff925e9a8a59.zip
move ABI check out to cover all calls
-rw-r--r--src/librustc_mir/interpret/terminator.rs48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs
index ad4613bf5b3..d6699752d7c 100644
--- a/src/librustc_mir/interpret/terminator.rs
+++ b/src/librustc_mir/interpret/terminator.rs
@@ -251,6 +251,30 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
             }
         };
 
+        // ABI check
+        {
+            let callee_abi = {
+                let instance_ty = instance.ty(*self.tcx);
+                match instance_ty.kind {
+                    ty::FnDef(..) =>
+                        instance_ty.fn_sig(*self.tcx).abi(),
+                    ty::Closure(..) => Abi::RustCall,
+                    ty::Generator(..) => Abi::Rust,
+                    _ => bug!("unexpected callee ty: {:?}", instance_ty),
+                }
+            };
+            let normalize_abi = |abi| match abi {
+                Abi::Rust | Abi::RustCall | Abi::RustIntrinsic | Abi::PlatformIntrinsic =>
+                    // These are all the same ABI, really.
+                    Abi::Rust,
+                abi =>
+                    abi,
+            };
+            if normalize_abi(caller_abi) != normalize_abi(callee_abi) {
+                throw_unsup!(FunctionAbiMismatch(caller_abi, callee_abi))
+            }
+        }
+
         match instance.def {
             ty::InstanceDef::Intrinsic(..) => {
                 assert!(caller_abi == Abi::RustIntrinsic || caller_abi == Abi::PlatformIntrinsic);
@@ -263,30 +287,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
             ty::InstanceDef::DropGlue(..) |
             ty::InstanceDef::CloneShim(..) |
             ty::InstanceDef::Item(_) => {
-                // ABI check
-                {
-                    let callee_abi = {
-                        let instance_ty = instance.ty(*self.tcx);
-                        match instance_ty.kind {
-                            ty::FnDef(..) =>
-                                instance_ty.fn_sig(*self.tcx).abi(),
-                            ty::Closure(..) => Abi::RustCall,
-                            ty::Generator(..) => Abi::Rust,
-                            _ => bug!("unexpected callee ty: {:?}", instance_ty),
-                        }
-                    };
-                    let normalize_abi = |abi| match abi {
-                        Abi::Rust | Abi::RustCall | Abi::RustIntrinsic | Abi::PlatformIntrinsic =>
-                            // These are all the same ABI, really.
-                            Abi::Rust,
-                        abi =>
-                            abi,
-                    };
-                    if normalize_abi(caller_abi) != normalize_abi(callee_abi) {
-                        throw_unsup!(FunctionAbiMismatch(caller_abi, callee_abi))
-                    }
-                }
-
                 // We need MIR for this fn
                 let body = match M::find_fn(self, instance, args, dest, ret, unwind)? {
                     Some(body) => body,