rust-lang / rust-lang/rust

Internal Tracking Issue for normalization redesign

Open
#155,345 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-technical-debt C-cleanup C-enhancement C-tracking-issue T-types WG-trait-system-refactor
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

This is a tracking issue to migrate the way we handle alias types (associated types, opaque types, etc) in the type system, and especially the next-generation trait solver -Znext-solver. This is a large change and requires a lot of churn, because of this, it will land in multiple steps.

This refactor includes the addition of a wrapper struct Unnormalized to explicitly track whether a type needs should be eagerly normalized. It also adds a IsRigid flag to TyKind::Alias, marking whether an alias is known to be rigid in the current context.

This is in progress and we've somewhat adjusted this design as we've tried to implement it. For a terse and likely slightly outdated description, see https://hackmd.io/d4spupEOTySQmkz1gaPk1g.

Please contact @lcnr on the #t-types zulip stream in case there are questions or issues. While we're changing this, please do not hesitate to reach out in case the current state is unclear or confusing. If you want to help out, see the links to messages in the #t-types/trait-system-refactor zulip.

Steps
Rigid aliases
  • type relating, first normalize aliases, then handle infer vars, this means generalization never results in an infer var :>
  • change coherence to actually rely on lazy norm :<
  • eagerly normalize when adding stuff to the fulfillment ctxt :> (blocked on removing the dependence on lazy norm in coherence)
  • change TypeOutlives handling to only expect rigid aliases, eagerly normalize https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/ask.20for.20help/near/607084889
  • properly use expect IsRigid::Yes in region handling
  • trying changing EarlyBinder::bind to assert that there are no rigid aliases instead of implicitly replacing rigid aliases (manually replace them before then)
  • TypeFolder try to do rigid to non rigid conversion automatically/make it harder to mess up
ty::Unnormalized cleanup

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked PRs and the messages in the #t-types/trait-system-refactor Zulip stream to understand which checklist item is still actionable. Choose one narrowly scoped item with guidance from the type-system maintainers, then update the corresponding checklist entry when its implementation and validation are complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.