Skip to content

Commit 91dcd42

Browse files
committed
Use Translatable Diagnostic
1 parent 218b339 commit 91dcd42

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

compiler/rustc_codegen_ssa/messages.ftl

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ codegen_ssa_copy_path_buf = unable to copy {$source_file} to {$output_path}: {$e
2222
2323
codegen_ssa_create_temp_dir = couldn't create a temp dir: {$error}
2424
25+
codegen_ssa_dangerous_stack_allocation = Dangerous stack allocation of size: {$output} exceeds most architecture limits
26+
2527
codegen_ssa_error_creating_remark_dir = failed to create remark directory: {$error}
2628
2729
codegen_ssa_expected_coverage_symbol = expected `coverage(off)` or `coverage(on)`

compiler/rustc_codegen_ssa/src/errors.rs

+6
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,12 @@ pub struct CheckInstalledVisualStudio;
413413
#[diag(codegen_ssa_insufficient_vs_code_product)]
414414
pub struct InsufficientVSCodeProduct;
415415

416+
#[derive(Diagnostic)]
417+
#[diag(codegen_ssa_dangerous_stack_allocation)]
418+
pub struct DangerousStackAllocation {
419+
pub output: String,
420+
}
421+
416422
#[derive(Diagnostic)]
417423
#[diag(codegen_ssa_processing_dymutil_failed)]
418424
#[note]

compiler/rustc_codegen_ssa/src/mir/mod.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::base;
2+
use crate::errors;
23
use crate::traits::*;
34
use rustc_index::bit_set::BitSet;
45
use rustc_index::IndexVec;
@@ -231,12 +232,9 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
231232
if layout.size.bytes() >= MIN_DANGEROUS_SIZE {
232233
let size_str = || {
233234
let (size_quantity, size_unit) = human_readable_bytes(layout.size.bytes());
234-
format!(
235-
"Dangerous stack allocation of size: {:.2} {} exceeds limits on most architectures",
236-
size_quantity, size_unit
237-
)
235+
format!("{:.2} {}", size_quantity, size_unit)
238236
};
239-
cx.tcx().dcx().fatal(size_str());
237+
cx.tcx().dcx().emit_warn(errors::DangerousStackAllocation { output: size_str() });
240238
}
241239

242240
if local == mir::RETURN_PLACE && fx.fn_abi.ret.is_indirect() {

tests/ui/codegen/issue-83060-large-stack-size.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// build-fail
1+
// build-pass
22
fn func() {
33
const CAP: usize = std::u32::MAX as usize;
44
let mut x: [u8; CAP>>1] = [0; CAP>>1];
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: Dangerous stack allocation of size: 1 GiB exceeds limits on most architectures
1+
warning: Dangerous stack allocation of size: 1 GiB exceeds most architecture limits
22

3-
error: aborting due to 1 previous error
3+
warning: 1 warning emitted
44

0 commit comments

Comments
 (0)