Description
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