Skip to content

Commit 44789b6

Browse files
committed
Add an ensure_sufficient_stack to LateContextAndPass::visit_expr
This is apparently where it's busting stack, and the comments for `ensure_sufficient_stack` say that > E.g. almost any call to visit_expr or equivalent can benefit from this.
1 parent 314c39d commit 44789b6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

compiler/rustc_lint/src/late.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
1717
use crate::{passes::LateLintPassObject, LateContext, LateLintPass, LintStore};
1818
use rustc_ast as ast;
19+
use rustc_data_structures::stack::ensure_sufficient_stack;
1920
use rustc_data_structures::sync::{join, DynSend};
2021
use rustc_hir as hir;
2122
use rustc_hir::def_id::LocalDefId;
@@ -157,10 +158,12 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
157158
}
158159

159160
fn visit_expr(&mut self, e: &'tcx hir::Expr<'tcx>) {
160-
self.with_lint_attrs(e.hir_id, |cx| {
161-
lint_callback!(cx, check_expr, e);
162-
hir_visit::walk_expr(cx, e);
163-
lint_callback!(cx, check_expr_post, e);
161+
ensure_sufficient_stack(|| {
162+
self.with_lint_attrs(e.hir_id, |cx| {
163+
lint_callback!(cx, check_expr, e);
164+
hir_visit::walk_expr(cx, e);
165+
lint_callback!(cx, check_expr_post, e);
166+
})
164167
})
165168
}
166169

0 commit comments

Comments
 (0)