From f822e28297e0d952658a22d03543b03cbd3e81f2 Mon Sep 17 00:00:00 2001 From: Soumik15630m Date: Wed, 1 Jul 2026 07:50:03 +0530 Subject: [PATCH] Report CodegenError::Unsupported as a rustc diagnostic instead of panicking --- src/base.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/base.rs b/src/base.rs index 2b30b55318..3c4410a2a0 100644 --- a/src/base.rs +++ b/src/base.rs @@ -220,6 +220,12 @@ pub(crate) fn compile_fn( ); early_dcx.early_fatal(format!("cranelift verify error:\n{}", pretty_error)); } + Err(ModuleError::Compilation(CodegenError::Unsupported(msg))) => { + let early_dcx = rustc_session::EarlyDiagCtxt::new( + rustc_session::config::ErrorOutputType::default(), + ); + early_dcx.early_fatal(format!("cranelift codegen error: {msg}")); + } Err(err) => { panic!("Error while defining {name}: {err:?}", name = codegened_func.symbol_name); }