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(); + }) }) }) }