Skip to content

Commit

Permalink
Unrolled build for rust-lang#122717
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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 rust-lang#122715
  • Loading branch information
rust-timer authored Mar 19, 2024
2 parents a385e56 + cdeb170 commit 3b2ed7e
Show file tree
Hide file tree
Showing 2 changed files with 4,911 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,10 @@ impl<'a> Parser<'a> {
// Stitch the list of outer attributes onto the return value.
// A little bit ugly, but the best way given the current code
// structure
let res = self.parse_expr_dot_or_call_with_(e0, lo);
let res = ensure_sufficient_stack(
// this expr demonstrates the recursion it guards against
|| self.parse_expr_dot_or_call_with_(e0, lo),
);
if attrs.is_empty() {
res
} else {
Expand Down
Loading

0 comments on commit 3b2ed7e

Please sign in to comment.