Skip to content

Commit 2c778c1

Browse files
committed
ensure sufficient stack in tail call check
1 parent 25a1657 commit 2c778c1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Diff for: compiler/rustc_mir_build/src/check_tail_calls.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use rustc_abi::ExternAbi;
2+
use rustc_data_structures::stack::ensure_sufficient_stack;
23
use rustc_errors::Applicability;
34
use rustc_hir::LangItem;
45
use rustc_hir::def::DefKind;
@@ -344,12 +345,14 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for TailCallCkVisitor<'a, 'tcx> {
344345
}
345346

346347
fn visit_expr(&mut self, expr: &'a Expr<'tcx>) {
347-
if let ExprKind::Become { value } = expr.kind {
348-
let call = &self.thir[value];
349-
self.check_tail_call(call, expr);
350-
}
348+
ensure_sufficient_stack(|| {
349+
if let ExprKind::Become { value } = expr.kind {
350+
let call = &self.thir[value];
351+
self.check_tail_call(call, expr);
352+
}
351353

352-
visit::walk_expr(self, expr);
354+
visit::walk_expr(self, expr);
355+
});
353356
}
354357
}
355358

0 commit comments

Comments
 (0)