Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exponential compile time with nested &dyn Fn type #104583

Closed
jruderman opened this issue Nov 18, 2022 · 0 comments · Fixed by #105350
Closed

Exponential compile time with nested &dyn Fn type #104583

jruderman opened this issue Nov 18, 2022 · 0 comments · Fixed by #105350
Assignees
Labels
C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times.

Comments

@jruderman
Copy link
Contributor

Found with a modified fuzz-rustc

Code

fn id(
    f: &dyn Fn(u32)
) -> &dyn Fn(
    &dyn Fn(
        &dyn Fn(
            &dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(&dyn Fn(u32)))))))))
        )
    )
) {
    f
}

fn main() {}

Time complexity

Seems exponential:

Nesting level Time
9 0.9 sec
10 4.2 sec
11 17 sec
12 80 sec

Where it's slow

Not a recent regression

It's slow at least as far back as nightly-2018-01-01

Version

rustc 1.67.0-nightly (a00f8ba7f 2022-11-15)
binary: rustc
commit-hash: a00f8ba7fcac1b27341679c51bf5a3271fa82df3
commit-date: 2022-11-15
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4

@rustbot label +I-compiletime

@jruderman jruderman added the C-bug Category: This is a bug. label Nov 18, 2022
@rustbot rustbot added the I-compiletime Issue: Problems and improvements with respect to compile times. label Nov 18, 2022
@compiler-errors compiler-errors self-assigned this Nov 19, 2022
@bors bors closed this as completed in 109cccb Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-compiletime Issue: Problems and improvements with respect to compile times.
Projects
None yet
3 participants