Skip to content

Commit 6ed4038

Browse files
committed
Only allow PassMode::Direct for aggregates on wasm when using the C ABI
For the Rust ABI we don't have any ABI compat reasons to allow PassMode::Direct for aggregates.
1 parent 0e98766 commit 6ed4038

File tree

1 file changed

+16
-7
lines changed
  • compiler/rustc_ty_utils/src

1 file changed

+16
-7
lines changed

compiler/rustc_ty_utils/src/abi.rs

+16-7
Original file line numberDiff line numberDiff line change
@@ -480,13 +480,22 @@ fn fn_abi_sanity_check<'tcx>(
480480
// The unstable abi `PtxKernel` also uses Direct for now.
481481
// It needs to switch to something else before stabilization can happen.
482482
// (See issue: https://github.com/rust-lang/rust/issues/117271)
483-
assert!(
484-
matches!(&*tcx.sess.target.arch, "wasm32" | "wasm64")
485-
|| matches!(spec_abi, ExternAbi::PtxKernel | ExternAbi::Unadjusted),
486-
"`PassMode::Direct` for aggregates only allowed for \"unadjusted\" and \"ptx-kernel\" functions and on wasm\n\
487-
Problematic type: {:#?}",
488-
arg.layout,
489-
);
483+
484+
match spec_abi {
485+
// The unadjusted ABI is ill specified, but unfortunately we need it for
486+
// calling certain LLVM intrinsics.
487+
ExternAbi::Unadjusted => {}
488+
ExternAbi::PtxKernel => {}
489+
ExternAbi::C { unwind: _ }
490+
if matches!(&*tcx.sess.target.arch, "wasm32" | "wasm64") => {}
491+
_ => {
492+
panic!(
493+
"`PassMode::Direct` for aggregates only allowed for \"unadjusted\" and \"ptx-kernel\" functions and on wasm\n\
494+
Problematic type: {:#?}",
495+
arg.layout,
496+
);
497+
}
498+
}
490499
}
491500
}
492501
}

0 commit comments

Comments
 (0)