when terminating during unwinding, show the reason why

This commit is contained in:
Ralf Jung 2023-08-21 09:57:10 +02:00
parent 18658cb0c9
commit 3f4145e169
2 changed files with 6 additions and 5 deletions

View File

@ -474,8 +474,8 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
*destination, *destination,
); );
} }
TerminatorKind::UnwindTerminate => { TerminatorKind::UnwindTerminate(reason) => {
codegen_panic_cannot_unwind(fx, source_info); codegen_unwind_terminate(fx, source_info, *reason);
} }
TerminatorKind::UnwindResume => { TerminatorKind::UnwindResume => {
// FIXME implement unwinding // FIXME implement unwinding
@ -971,13 +971,14 @@ pub(crate) fn codegen_panic_nounwind<'tcx>(
codegen_panic_inner(fx, rustc_hir::LangItem::PanicNounwind, &args, source_info.span); codegen_panic_inner(fx, rustc_hir::LangItem::PanicNounwind, &args, source_info.span);
} }
pub(crate) fn codegen_panic_cannot_unwind<'tcx>( pub(crate) fn codegen_unwind_terminate<'tcx>(
fx: &mut FunctionCx<'_, '_, 'tcx>, fx: &mut FunctionCx<'_, '_, 'tcx>,
source_info: mir::SourceInfo, source_info: mir::SourceInfo,
reason: UnwindTerminateReason,
) { ) {
let args = []; let args = [];
codegen_panic_inner(fx, rustc_hir::LangItem::PanicCannotUnwind, &args, source_info.span); codegen_panic_inner(fx, reason.lang_item(), &args, source_info.span);
} }
fn codegen_panic_inner<'tcx>( fn codegen_panic_inner<'tcx>(

View File

@ -551,7 +551,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
TerminatorKind::Goto { .. } TerminatorKind::Goto { .. }
| TerminatorKind::SwitchInt { .. } | TerminatorKind::SwitchInt { .. }
| TerminatorKind::UnwindResume | TerminatorKind::UnwindResume
| TerminatorKind::UnwindTerminate | TerminatorKind::UnwindTerminate(_)
| TerminatorKind::Return | TerminatorKind::Return
| TerminatorKind::Unreachable | TerminatorKind::Unreachable
| TerminatorKind::Drop { .. } | TerminatorKind::Drop { .. }