From 5aa2a90724e2f647cf118f0a80bffab46b5a36d6 Mon Sep 17 00:00:00 2001 From: Binlogo Date: Wed, 29 Oct 2025 21:21:25 +0800 Subject: [PATCH] Improve diagnose for unconditional panic when resource limit --- compiler/rustc_interface/src/util.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 5e9cb42365049..1ddde9340916f 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -287,7 +287,15 @@ pub(crate) fn run_in_thread_pool_with_globals< pool.install(|| f(current_gcx.into_inner(), proxy)) }, ) - .unwrap() + .unwrap_or_else(|err| { + let mut diag = thread_builder_diag.early_struct_fatal(format!( + "failed to spawn compiler thread pool: could not create {threads} threads ({err})", + )); + diag.help( + "try lowering `-Z threads` or checking the operating system's resource limits", + ); + diag.emit(); + }) }) }) }