about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRémy Rakic <remy.rakic@gmail.com>2025-01-31 13:05:10 +0100
committerJosh Stone <jistone@redhat.com>2025-02-06 09:53:26 -0800
commit741fa9e39f5eb0e70fbb08176602c30538e404d6 (patch)
tree25bf5d79a234c2f3fb948989c84ec1da1eabb78b
parent940548094b669fa05ed1a3015945cc567790d9f4 (diff)
ensure sufficient stack in tail call check
(cherry picked from commit 2c778c1e4ca8053e787998c9b18bb57222719a3d)
-rw-r--r--compiler/rustc_mir_build/src/check_tail_calls.rs13
1 files changed, 8 insertions, 5 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);
+        });
     }
 }