Skip to content
This repository was archived by the owner on Jul 14, 2018. It is now read-only.
This repository was archived by the owner on Jul 14, 2018. It is now read-only.

Trait system rewrite #8

Open
Open
@aturon

Description

@aturon

Point of contact

@nikomatsakis @aturon

Overview

The current trait system implementation is written in a "direct" style, where we perform search directly on impls and so on. While we've taken pains to keep this implementation clean, it's still quite complicated and ad hoc, and has a number of pitfalls:

  • Performance is limited by the amount of caching we can perform. Caching currently takes into account irrelevant information, meaning that cache misses are more common than they should be. Changing this in the current setup is not easy.

  • There are a lot of limitations around associated types and higher-ranked trait bounds, which again are hard to lift within the current setup.

  • There are a number of extensions we'd like to make to the trait system, but doing so would require substantial refactorings.

We're now exploring a re-write based on logic programming, where we understand traits and impls as a logic program against which we can make queries. This should allow for a much more principled implementation, better caching, and easier extension to new features (like associated type constructors).

Status

The Chalk project is a standalone trait system/prolog engine, which serves as a prototype and specification for what we want in rustc itself. It's quite far along at this point, but is still missing a few crucial pieces (like specialization).

We're also doing some refactoring in rustc, ahead of the work to port Chalk's ideas into rustc proper.

In the long run, we'd like to have the ability to run Chalk side-by-side with rustc, as an addon to the compiler's test suite.

Blog posts:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions