rust-lang / types-team

Home of the "types team", affiliated with the compiler and lang teams.
https://rust-lang.github.io/types-team/
Apache License 2.0
94 stars 19 forks source link

merge rigid types in `TyKind` into a single variant. #64

Closed lcnr closed 1 year ago

lcnr commented 1 year ago

Proposal

Incrementally work towards merging all variants which are rigid type constructors with the goal of having the following final enum:

enum RigidTy<'tcx> {
    Bool,
    Char,
    // ...
}

enum TyKind<'tcx> {
    Rigid(RigidTy<'tcx>, SubstsRef<'tcx>),
    /// We can keep `Projection` and `Opaque` separate for now.
    Alias(AliasTy<'tcx>, SubstsRef<'tcx>),
    Infer(...),
    Placeholder(...),
    Bound(...),
    Error(...),
}

This greatly simplifies type relations and makes it easier to use a TypeFolder for generalization, as getting variance right will be a lot easier by adding a method fn RigidTy::variances(self) -> &'tcx [ty::Variance] which we then use to relate the SubstsRef.

It should have a minimal (potentially even positive) impact on performance and a noticeable impact on readability.

Mentors or Reviewers

I am up to mentor and review this work.

Process

The main points of the Major Change Process are as follows:

You can read more about Major Change Proposals on forge.

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, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

rustbot commented 1 year ago

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

lcnr commented 1 year ago

closing this due to concerns over perf https://rust-lang.zulipchat.com/#narrow/stream/326866-t-types.2Fnominated/topic/merge.20rigid.20types.20in.20.60TyKind.60.20into.20a.20single.20v.E2.80.A6.20types-team.2364