Skip to content

Exponential parse time involving recover_const_arg #103620

Open
@jruderman

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.

sample-head-103620.txt

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

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-compiletimeIssue: Problems and improvements with respect to compile times.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions