@@ -232,26 +232,28 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
232232
233233 // ABI check
234234 let check_abi = |this : & Self , instance_ty : Ty < ' tcx > | -> InterpResult < ' tcx > {
235- let callee_abi = match instance_ty. kind ( ) {
236- ty:: FnDef ( ..) => instance_ty. fn_sig ( * this. tcx ) . abi ( ) ,
237- ty:: Closure ( ..) => Abi :: RustCall ,
238- ty:: Generator ( ..) => Abi :: Rust ,
239- _ => span_bug ! ( this. cur_span( ) , "unexpected callee ty: {:?}" , instance_ty) ,
240- } ;
241- let normalize_abi = |abi| match abi {
242- Abi :: Rust | Abi :: RustCall | Abi :: RustIntrinsic | Abi :: PlatformIntrinsic =>
243- // These are all the same ABI, really.
244- {
245- Abi :: Rust
235+ if M :: enforce_abi ( this) {
236+ let callee_abi = match instance_ty. kind ( ) {
237+ ty:: FnDef ( ..) => instance_ty. fn_sig ( * this. tcx ) . abi ( ) ,
238+ ty:: Closure ( ..) => Abi :: RustCall ,
239+ ty:: Generator ( ..) => Abi :: Rust ,
240+ _ => span_bug ! ( this. cur_span( ) , "unexpected callee ty: {:?}" , instance_ty) ,
241+ } ;
242+ let normalize_abi = |abi| match abi {
243+ Abi :: Rust | Abi :: RustCall | Abi :: RustIntrinsic | Abi :: PlatformIntrinsic =>
244+ // These are all the same ABI, really.
245+ {
246+ Abi :: Rust
247+ }
248+ abi => abi,
249+ } ;
250+ if normalize_abi ( caller_abi) != normalize_abi ( callee_abi) {
251+ throw_ub_format ! (
252+ "calling a function with ABI {} using caller ABI {}" ,
253+ callee_abi. name( ) ,
254+ caller_abi. name( )
255+ )
246256 }
247- abi => abi,
248- } ;
249- if normalize_abi ( caller_abi) != normalize_abi ( callee_abi) {
250- throw_ub_format ! (
251- "calling a function with ABI {} using caller ABI {}" ,
252- callee_abi. name( ) ,
253- caller_abi. name( )
254- )
255257 }
256258 Ok ( ( ) )
257259 } ;
0 commit comments