From b6d0d6da553d3836767b484530b23ad89807f470 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sun, 19 May 2024 19:59:06 -0700 Subject: [PATCH] note value of RUST_MIN_STACK and explain unsetting --- compiler/rustc_interface/src/util.rs | 12 +++++++++--- tests/ui/rustc-env/min-stack-banana.stderr | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index f549ae49012e0..ce2382b950193 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -65,9 +65,15 @@ fn init_stack_size(early_dcx: &EarlyDiagCtxt) -> usize { // so no one thinks we parsed them setting `RUST_MIN_STACK="64 megabytes"` // FIXME: we could accept `RUST_MIN_STACK=64MB`, perhaps? .map(|s| { - s.trim().parse::().unwrap_or_else(|_| { - #[allow(rustc::untranslatable_diagnostic)] - early_dcx.early_fatal("`RUST_MIN_STACK` should be unset or a number of bytes") + let s = s.trim(); + // FIXME(workingjubilee): add proper diagnostics when we factor out "pre-run" setup + #[allow(rustc::untranslatable_diagnostic, rustc::diagnostic_outside_of_impl)] + s.parse::().unwrap_or_else(|_| { + let mut err = early_dcx.early_struct_fatal(format!( + r#"`RUST_MIN_STACK` should be a number of bytes, but was "{s}""#, + )); + err.note("you can also unset `RUST_MIN_STACK` to use the default stack size"); + err.emit() }) }) // otherwise pick a consistent default diff --git a/tests/ui/rustc-env/min-stack-banana.stderr b/tests/ui/rustc-env/min-stack-banana.stderr index a8b46d8ae446a..d379367ab4f7f 100644 --- a/tests/ui/rustc-env/min-stack-banana.stderr +++ b/tests/ui/rustc-env/min-stack-banana.stderr @@ -1,2 +1,4 @@ -error: `RUST_MIN_STACK` should be unset or a number of bytes +error: `RUST_MIN_STACK` should be a number of bytes, but was "banana" + | + = note: you can also unset `RUST_MIN_STACK` to use the default stack size