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.
This commit is contained in:
parent
3c85e56249
commit
cdeb170fc2
2 changed files with 4911 additions and 1 deletions
|
@ -943,7 +943,10 @@ impl<'a> Parser<'a> {
|
||||||
// Stitch the list of outer attributes onto the return value.
|
// Stitch the list of outer attributes onto the return value.
|
||||||
// A little bit ugly, but the best way given the current code
|
// A little bit ugly, but the best way given the current code
|
||||||
// structure
|
// 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() {
|
if attrs.is_empty() {
|
||||||
res
|
res
|
||||||
} else {
|
} else {
|
||||||
|
|
4907
tests/ui/parser/survive-peano-lesson-queue.rs
Normal file
4907
tests/ui/parser/survive-peano-lesson-queue.rs
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue