diff options
| author | Gary Guo <gary@garyguo.net> | 2022-05-11 23:08:02 +0100 |
|---|---|---|
| committer | Gary Guo <gary@garyguo.net> | 2022-05-12 00:03:48 +0100 |
| commit | c586bc3d760c4cb158aba5c59ca15809a6957142 (patch) | |
| tree | 822ae1e258cbfa758668a26c2586efa5885c680a /compiler/rustc_middle/src | |
| parent | 6dd68402c5d7da168f87d8551dd9aed1d8a21893 (diff) | |
| download | rust-c586bc3d760c4cb158aba5c59ca15809a6957142.tar.gz rust-c586bc3d760c4cb158aba5c59ca15809a6957142.zip | |
Prevent unwinding when `-C panic=abort` is used regardless declared ABI
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/layout.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index c8055100d30..630a89cc7cb 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -2888,6 +2888,14 @@ pub fn fn_can_unwind<'tcx>(tcx: TyCtxt<'tcx>, fn_def_id: Option<DefId>, abi: Spe return false; } + // With `-C panic=abort`, all non-FFI functions are required to not unwind. + // + // Note that this is true regardless ABI specified on the function -- a `extern "C-unwind"` + // function defined in Rust is also required to abort. + if tcx.sess.panic_strategy() == PanicStrategy::Abort && !tcx.is_foreign_item(did) { + return false; + } + // With -Z panic-in-drop=abort, drop_in_place never unwinds. // // This is not part of `codegen_fn_attrs` as it can differ between crates |
