From c4f2d21f1a9e41c025cc8cfca5f5f06053aba70e Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Sat, 29 Jan 2022 11:54:16 +0000 Subject: [PATCH] Mark the panic_no_unwind lang item as nounwind --- compiler/rustc_typeck/src/collect.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index cf519a9ab327..7c8a47d5d652 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -2778,6 +2778,13 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs { } } + // The panic_no_unwind function called by TerminatorKind::Abort will never + // unwind. If the panic handler that it invokes unwind then it will simply + // call the panic handler again. + if Some(id) == tcx.lang_items().panic_no_unwind() { + codegen_fn_attrs.flags |= CodegenFnAttrFlags::NEVER_UNWIND; + } + let supported_target_features = tcx.supported_target_features(LOCAL_CRATE); let mut inline_span = None;