diff options
| author | bors <bors@rust-lang.org> | 2025-02-03 13:56:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-02-03 13:56:04 +0000 |
| commit | f2c4ccd852f68fb36dedc033239cb7c0fb1921ef (patch) | |
| tree | 5ca9fc529fb074ef5e1759880bac7b58689ca296 /compiler | |
| parent | a5db378dc14a40dd1580c27fb8362156446382c3 (diff) | |
| parent | 94562ee1eae83d6cc80bda4d57b43bcdb7a842b5 (diff) | |
| download | rust-f2c4ccd852f68fb36dedc033239cb7c0fb1921ef.tar.gz rust-f2c4ccd852f68fb36dedc033239cb7c0fb1921ef.zip | |
Auto merge of #136352 - lqd:ensure-stacks, r=compiler-errors
Add a couple of missing `ensure_sufficient_stacks` r? `@saethlin` I hope you didn't spend time on this already. (I couldn't sleep, opened `check_tail_calls`, there was a single call where it could happen, might as well fix it) This PR adds a couple of missing `ensure_sufficient_stack`s: - one in `check_tail_calls` that prevented the #135709 backport on some targets. - after that was fixed, the test still didn't pass starting at 4MB, so I also added one in `check_unsafety` and that made it pass. I didn't add an `rmake` test purposefully limiting the min stack size on `issue-74564-if-expr-stack-overflow.rs`, but we could if we wanted to. On `apple-aarch64-darwin`, this is enough to make `RUST_MIN_STACK=$((1024*1024*3)) ./x test tests/ui --test-args tests/ui/issues/issue-74564-if-expr-stack-overflow.rs` pass for me locally, and it does stack overflow otherwise.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_mir_build/src/check_tail_calls.rs | 13 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/check_unsafety.rs | 5 |
2 files changed, 12 insertions, 6 deletions
diff --git a/compiler/rustc_mir_build/src/check_tail_calls.rs b/compiler/rustc_mir_build/src/check_tail_calls.rs index 0659e3ea314..921205428db 100644 --- a/compiler/rustc_mir_build/src/check_tail_calls.rs +++ b/compiler/rustc_mir_build/src/check_tail_calls.rs @@ -1,4 +1,5 @@ use rustc_abi::ExternAbi; +use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_errors::Applicability; use rustc_hir::LangItem; use rustc_hir::def::DefKind; @@ -344,12 +345,14 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for TailCallCkVisitor<'a, 'tcx> { } fn visit_expr(&mut self, expr: &'a Expr<'tcx>) { - if let ExprKind::Become { value } = expr.kind { - let call = &self.thir[value]; - self.check_tail_call(call, expr); - } + ensure_sufficient_stack(|| { + if let ExprKind::Become { value } = expr.kind { + let call = &self.thir[value]; + self.check_tail_call(call, expr); + } - visit::walk_expr(self, expr); + visit::walk_expr(self, expr); + }); } } diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index e47c14b8bfa..b6494173b0f 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -2,6 +2,7 @@ use std::borrow::Cow; use std::mem; use std::ops::Bound; +use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_errors::DiagArgValue; use rustc_hir::def::DefKind; use rustc_hir::{self as hir, BindingMode, ByRef, HirId, Mutability}; @@ -476,7 +477,9 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> { ExprKind::Scope { value, lint_level: LintLevel::Explicit(hir_id), region_scope: _ } => { let prev_id = self.hir_context; self.hir_context = hir_id; - self.visit_expr(&self.thir[value]); + ensure_sufficient_stack(|| { + self.visit_expr(&self.thir[value]); + }); self.hir_context = prev_id; return; // don't visit the whole expression } |
