Skip to content

Expotential compile time with recursive trait boundsΒ #75542

Open
@weiznich

Description

@weiznich

While developing diesel we've hit a surprising increase in compile time caused by our trait impls for tuples. See diesel-rs/diesel#2480 for details. I've extracted a somewhat minimal example here. There is an option to control the tuple size up to which traits should be implemented in line 861. For a size of 16 the compilation of the example succeeds in less then 2 seconds using the rust-playground + the current stable compiler. For a tuple size > 20 the playground is terminated. (Diesel takes ~30s to build while implementing traits for tuples up to 16 elements, and 17 minutes while implementing traits for tuples up to 32 elements for my local setup).

I suspect that this is caused by the combination of a having a recursive trait bound here + enforcing that bound for each tuple size here. Diesel itself has not only one trait that requires Self: SqlType, but probably the problem is increased by that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemC-bugCategory: This is a bug.I-compiletimeIssue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions