-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Nested closures result in exponential compilation time increase #72408
Copy link
Copy link
Closed
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)C-bugCategory: This is a bug.Category: This is a bug.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)C-bugCategory: This is a bug.Category: This is a bug.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Closures include captured types twice in a type tree.
Wrapping one closure with another leads to doubling the amount of types in the type tree.
With nested closures compile time increases exponentially and it's extremely easy to break the compiler. Obviously it's even easier if each level captures more than one closure.
I think I have a fix for this one ready, about to push it.
I tried this code:
I expected to see this happen: no error.
Instead, this happened:
Meta
I tried it both on stable and nightly rust: