From 3d4a9f504780dd8f9ba4e7921cce8d8517c20aa6 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Fri, 9 Feb 2024 20:22:15 -0500 Subject: [PATCH] Turn the "no saved object file in work product" ICE into a translatable fatal error --- compiler/rustc_codegen_ssa/messages.ftl | 2 ++ compiler/rustc_codegen_ssa/src/back/write.rs | 4 +++- compiler/rustc_codegen_ssa/src/errors.rs | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_ssa/messages.ftl b/compiler/rustc_codegen_ssa/messages.ftl index a80f6a1add0..fa7719d8971 100644 --- a/compiler/rustc_codegen_ssa/messages.ftl +++ b/compiler/rustc_codegen_ssa/messages.ftl @@ -190,6 +190,8 @@ codegen_ssa_no_module_named = codegen_ssa_no_natvis_directory = error enumerating natvis directory: {$error} +codegen_ssa_no_saved_object_file = cached cgu {$cgu_name} should have an object file, but doesn't + codegen_ssa_processing_dymutil_failed = processing debug info with `dsymutil` failed: {$status} .note = {$output} diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 9b24339d255..a63642d76b9 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -913,7 +913,9 @@ fn execute_copy_from_cache_work_item( let object = load_from_incr_comp_dir( cgcx.output_filenames.temp_path(OutputType::Object, Some(&module.name)), - module.source.saved_files.get("o").expect("no saved object file in work product"), + module.source.saved_files.get("o").unwrap_or_else(|| { + cgcx.create_dcx().emit_fatal(errors::NoSavedObjectFile { cgu_name: &module.name }) + }), ); let dwarf_object = module.source.saved_files.get("dwo").as_ref().and_then(|saved_dwarf_object_file| { diff --git a/compiler/rustc_codegen_ssa/src/errors.rs b/compiler/rustc_codegen_ssa/src/errors.rs index 06ea5b9e8f4..3d7903b5efb 100644 --- a/compiler/rustc_codegen_ssa/src/errors.rs +++ b/compiler/rustc_codegen_ssa/src/errors.rs @@ -121,6 +121,12 @@ pub struct NoNatvisDirectory { pub error: Error, } +#[derive(Diagnostic)] +#[diag(codegen_ssa_no_saved_object_file)] +pub struct NoSavedObjectFile<'a> { + pub cgu_name: &'a str, +} + #[derive(Diagnostic)] #[diag(codegen_ssa_copy_path_buf)] pub struct CopyPathBuf {