Skip to content

ConstParamTy should be split into two traits #112221

Closed
@BoxyUwU

Description

@BoxyUwU

ConstParamTy is currently used to require people to opt-in to having a type used as a const parameter under feature(adt_const_params) as not all types are legal to have as a const parameter type. One of the restrictions impls of this trait have is that the type has Eq, PartialEq recursively derived. This is also something that pattern matching is interested so we should find some way of sharing the impl between ConstParamTy and the trait used for allowing constants to be used as patterns.

The current ConstParamTy trait should be split out into trait ConstParamTy: StructuralMatch and trait StructuralMatch: PartialEq + StructuralPartialEq with StructuralMatch also having a builtin check that all its fields are StructuralMatch.

It's possible that the requirements for const parameter types may end up being stricter than the requirements to use a constant as a pattern so we should have two separate traits rather than renaming ConstParamTy to something that makes sense in the context of pattern matching.

cc @oli-obk

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)A-patternsRelating to patterns and pattern matchingF-adt_const_params`#![feature(adt_const_params)]`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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions