Skip to content

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

@BoxyUwU

Description

@BoxyUwU

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.

Metadata

Metadata

Assignees

Labels

A-associated-itemsArea: Associated items (types, constants & functions)A-const-genericsArea: const generics (parameters and arguments)A-type-systemArea: Type systemC-cleanupCategory: PRs that clean code up or issues documenting cleanup.F-inherent_associated_types`#![feature(inherent_associated_types)]`F-min_generic_const_args`#![feature(min_generic_const_args)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions