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

rustc trait system rewrite initiative #58

Closed
lcnr opened this issue Oct 27, 2022 · 22 comments
Closed

rustc trait system rewrite initiative #58

lcnr opened this issue Oct 27, 2022 · 22 comments
Labels
final-comment-period The FCP has started, most (if not all) team members are in agreement finished-final-comment-period The FCP has finished, action upon the disposition label needs to be taken major-change A major change proposal T-types Add this label so rfcbot knows to poll the types team to-announce Announce this issue on triage meeting

Comments

@lcnr
Copy link
Contributor

lcnr commented Oct 27, 2022

Proposal

Start an initiative with the goal of replacing the current trait system implementation of rustc. This new implementation should fully replace both fulfill and evaluate and offer an API a lot closer to the ideal of chalk/a-mir-formality.

Goals of this initiative

  • greatly simplify future changes to the trait system, unblocking features like marker traits and fixes for existing soundness bugs
  • better learnability, the current system is difficult to learn and understand
  • far better1 caching with an estimated impact of
    • reducing compilation-time of some real world crates to less than half
    • for less type-heavy crates 0% and 15% improvements
    • in rare cases, may initially slightly worsen performance
  • reduces the chance of trait system bugs in the future

Explicit non-goals of this initiative

This initiative does not intend to implement any major changes to the trait system as part of the replacement. The new replacement should closely mirror the old system at the time of replacement to minimize the risk of backwards compatibility issues.

We also do not intend to extract any shared code with rust-analyzer as part of this initiative. While that will be easier after this work has been completed, the sole focus of this initiative is to replace the existing solvers with a solver which results in the advantages noted above.

Outline of the planned work

Start by clearly laying out how the compiler uses the existing trait solvers and what API has to be provided by the new solver.

Any parts strongly tied to the architecture of the current solvers have to be rewritten where possible. The biggest challenge will be trait diagnostics, which should be rewritten to be as solver agnostic as possible. Instead of relying on solver internals, diagnostics should lazily recompute necessary information where possible. This may require a reimplementation of our trait diagnostics to replace the existing one.

Once this is done, work on a new solver directly in rustc to replace both evaluate and fulfill. When that solver is ready, replace all uses of evaluate and fulfill with the new solver and remove evaluate and fulfill. At that point this initiative can be closed again.

For more information, see this document

Initial members

@lcnr as lead, other Types Team members depending on interest.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review or raising a concern that you would like to be addressed.

Footnotes

  1. currently different FnCtxt and ObligationCtxt do not share a cache for fulfill and also don't share it with mir borrowck.

@lcnr lcnr added the major-change A major change proposal label Oct 27, 2022
@rustbot
Copy link
Collaborator

rustbot commented Oct 27, 2022

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

cc @rust-lang/types

@rustbot rustbot added the to-announce Announce this issue on triage meeting label Oct 27, 2022
@lcnr

This comment was marked as outdated.

@lcnr

This comment was marked as outdated.

@lcnr

This comment was marked as outdated.

@lcnr lcnr added the T-types Add this label so rfcbot knows to poll the types team label Oct 27, 2022
@lcnr

This comment was marked as outdated.

@lcnr

This comment was marked as outdated.

@lcnr

This comment was marked as outdated.

@lcnr

This comment was marked as outdated.

@lcnr

This comment was marked as outdated.

@rfcbot
Copy link

rfcbot commented Oct 27, 2022

Team member @lcnr has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot

This comment was marked as off-topic.

@rfcbot

This comment was marked as off-topic.

@compiler-errors
Copy link
Member

other Types Team members depending on interest.

You already know that I'm interested 😃

@spastorino
Copy link
Member

other Types Team members depending on interest.

I'm interested too :)

@cjgillot
Copy link

other Types Team members depending on interest.

Do you accept out of types team also? I'd be interested.

@jackh726
Copy link
Member

other Types Team members depending on interest.

Do you accept out of types team also? I'd be interested.

Of course :)

@BoxyUwU
Copy link
Member

BoxyUwU commented Oct 27, 2022

I'd also be interested in helping with this

@nikomatsakis
Copy link
Contributor

@rfcbot reviewed

@vincenzopalazzo
Copy link
Member

Looks like to have my interest too :)

@rfcbot
Copy link

rfcbot commented Oct 28, 2022

🔔 This is now entering its final comment period, as per the review above. 🔔

psst @lcnr, I wasn't able to add the final-comment-period label, please do so.

@lcnr lcnr added the final-comment-period The FCP has started, most (if not all) team members are in agreement label Oct 28, 2022
@rfcbot
Copy link

rfcbot commented Nov 7, 2022

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

psst @lcnr, I wasn't able to add the finished-final-comment-period label, please do so.

@lcnr lcnr added the finished-final-comment-period The FCP has finished, action upon the disposition label needs to be taken label Nov 7, 2022
@jackh726
Copy link
Member

Closing as accepted 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
final-comment-period The FCP has started, most (if not all) team members are in agreement finished-final-comment-period The FCP has finished, action upon the disposition label needs to be taken major-change A major change proposal T-types Add this label so rfcbot knows to poll the types team to-announce Announce this issue on triage meeting
Projects
None yet
Development

No branches or pull requests

10 participants