ConstParamTy should be split into two traits #112221
Labels
A-const-generics
Area: const generics (parameters and arguments)
A-patterns
Relating to patterns and pattern matching
F-adt_const_params
`#![feature(adt_const_params)]`
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
ConstParamTy
is currently used to require people to opt-in to having a type used as a const parameter underfeature(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 hasEq, PartialEq
recursively derived. This is also something that pattern matching is interested so we should find some way of sharing the impl betweenConstParamTy
and the trait used for allowing constants to be used as patterns.The current
ConstParamTy
trait should be split out intotrait ConstParamTy: StructuralMatch
andtrait StructuralMatch: PartialEq + StructuralPartialEq
withStructuralMatch
also having a builtin check that all its fields areStructuralMatch
.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
The text was updated successfully, but these errors were encountered: