Skip to content

Commit d127901

Browse files
committed
Auto merge of #145410 - cuviper:expand-stack, r=lqd
rustc_expand: ensure stack in `InvocationCollector::visit_expr` In Fedora, when we built rustc with PGO on ppc64le, we started failing the test `issue-74564-if-expr-stack-overflow.rs`. This could also be reproduced on other arches by setting a smaller `RUST_MIN_STACK`, so it's probably just unlucky that ppc64le PGO created a large stack frame somewhere in this recursion path. Adding an `ensure_sufficient_stack` solves the stack overflow. Historically, that test and its fix were added in #74708, which was also an `ensure_sufficient_stack` in this area of code at the time. However, the refactor in #92573 basically left that to the general `MutVisitor`, and then #142240 removed even that ensure call. It may be luck that our tier-1 tested targets did not regress the original issue across those refactors.
2 parents 8e3710e + f68bcb3 commit d127901

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

compiler/rustc_expand/src/expand.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use rustc_ast::{
1414
use rustc_ast_pretty::pprust;
1515
use rustc_attr_parsing::{EvalConfigResult, ShouldEmit};
1616
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
17+
use rustc_data_structures::stack::ensure_sufficient_stack;
1718
use rustc_errors::PResult;
1819
use rustc_feature::Features;
1920
use rustc_hir::def::MacroKinds;
@@ -2469,7 +2470,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
24692470
if let Some(attr) = node.attrs.first() {
24702471
self.cfg().maybe_emit_expr_attr_err(attr);
24712472
}
2472-
self.visit_node(node)
2473+
ensure_sufficient_stack(|| self.visit_node(node))
24732474
}
24742475

24752476
fn visit_method_receiver_expr(&mut self, node: &mut ast::Expr) {

0 commit comments

Comments
 (0)