rust-lang / rust-lang/rust

move `Alias[Ty|Const|Term]Kind` into `Alias[Ty|Const|Term]`, generalize to not require just a `DefId`

Open
#152,245 5 comments 0 reactions 1 assignee View on GitHub

@khyperia is already working on this.

Since Jun 2, 2026.

A-associated-items A-const-generics A-type-system C-cleanup F-inherent_associated_types F-min_generic_const_args T-compiler T-types
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

ty::Ty has a Alias(AliasTyKind, DefId, GenericArgs) variant, whereas ty::Const just has Unevaluated(DefId, GenericArgs).

With mGCA we now have more than just anon consts in Unevaluated and have ways of normalizing that are not by invoking CTFE so this naming no longer makes sense. We're also starting to write code that wants to know what kind of const alias its interacting with (e.g. a projection, inherent, free, etc). This is really easy to check with types but with const generics we have to write awkward code matching on DefKinds and parents.

I expect consts will probably want to go one step further than types and have different representations for different kinds of unnormalized consts. E.g.

struct AliasConst(DefId, GenericArgs);

enum AliasConstKind {
    Inherent, Projection, Free, 
}

enum BikeshedConst {
    ConstItem(AliasConstKind, AliasConst),
    Literal(Ty, LitKind, bool),
    // add stuff which was previously in `ty::ExprKind`
}

enum ConstKind {
    ...

    // remove these
    Expr(ty::Expr),
    Unevaluated(ty::UnevaluatedConst),
    // replace with this
    Bikeshed(ty::BikeshedConst),
}

I'm not sure exactly what we should call Bikeshed/BikeshedConst, maybe just Expr works idk :3

This issue has been assigned to @khyperia via this comment.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.