Exponential parse time involving recover_const_arg
#103620
Open
Description
This code takes minutes to parse:
fn main() {
0 +
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
{ let _ : A<B<C = D, x:^
}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
}
The output (with --error-format=short
) includes:
src/main.rs:32:32: error: expected one of `!`, `(`, `,`, `>`, `?`, `for`, `~`, lifetime, or path, found `^`
src/main.rs:31:32: error: expected one of `!`, `(`, `,`, `>`, `?`, `for`, `~`, lifetime, or path, found `^`
src/main.rs:30:32: error: expected one of `!`, `(`, `,`, `>`, `?`, `for`, `~`, lifetime, or path, found `^`
...
where each error takes significantly longer to produce than the previous.
Where it's slow
According to -Z time-passes
, the slow pass is parse_crate
.
handle_ambiguous_unbraced_const_arg
and recover_const_arg
repeatedly on the stack is sus.
Impact
This input is nonsense, so it's possible the only impact of the issue is slowing down fuzzing, very slightly.
Version
rustc --version --verbose
:
rustc 1.66.0-nightly (bed4ad65b 2022-10-25)
binary: rustc
commit-hash: bed4ad65bf7a1cef39e3d66b3670189581b3b073
commit-date: 2022-10-25
host: x86_64-apple-darwin
release: 1.66.0-nightly
LLVM version: 15.0.2
Regression
Regression in nightly-2020-10-28
@rustbot label +I-compiletime