Skip to content

Exponential compile time with let in unsupported position within closure #104871

Open
@jruderman

Description

@jruderman

Found with a modified fuzz-rustc

Code

Variant A: slow and high memory use
fn main () {
    let z = 0_u32; 

    let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    || let _ =
    z;
}
Variant B: slow only
fn main () {
    let _clos = || { 
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        let _ =
        0_u32; 
    };
}

Where it's slow

From -Z time-passes:

  • item_bodies_checking

From sample-head.txt:

  • ExprUseVisitor when called by rustc_hir_typeck::upvar::FnCtxt::analyze_closure

Regression

Regression in nightly-2021-08-17, perhaps from #80357

Version

rustc 1.67.0-nightly (ff8c8dfbe 2022-11-22)
binary: rustc
commit-hash: ff8c8dfbe66701531e3e5e335c28c544d0fbc945
commit-date: 2022-11-22
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4

(Doesn't reproduce on playground)

@rustbot label +I-compiletime

Metadata

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