Skip to content

Commit 6561890

Browse files
authored
Rollup merge of #122717 - workingjubilee:handle-call-call-call-call-calling-me-maybe, r=compiler-errors
Ensure stack before parsing dot-or-call There are many cases where, due to codegen or a massively unruly codebase, a deeply nested `call(call(call(call(call(call(call(call(call(f())))))))))` can happen. This is a spot where it would be good to grow our stack, so that we can survive to tell the programmer their code is dubiously written. Closes #122715
2 parents ea7ea2d + cdeb170 commit 6561890

File tree

2 files changed

+4911
-1
lines changed

2 files changed

+4911
-1
lines changed

Diff for: compiler/rustc_parse/src/parser/expr.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,10 @@ impl<'a> Parser<'a> {
943943
// Stitch the list of outer attributes onto the return value.
944944
// A little bit ugly, but the best way given the current code
945945
// structure
946-
let res = self.parse_expr_dot_or_call_with_(e0, lo);
946+
let res = ensure_sufficient_stack(
947+
// this expr demonstrates the recursion it guards against
948+
|| self.parse_expr_dot_or_call_with_(e0, lo),
949+
);
947950
if attrs.is_empty() {
948951
res
949952
} else {

0 commit comments

Comments
 (0)