Skip to content

Commit

Permalink
note value of RUST_MIN_STACK and explain unsetting
Browse files Browse the repository at this point in the history
  • Loading branch information
workingjubilee committed May 20, 2024
1 parent 9985821 commit b6d0d6d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 9 additions & 3 deletions compiler/rustc_interface/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<usize>().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::<usize>().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
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/rustc-env/min-stack-banana.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b6d0d6d

Please sign in to comment.