Skip to content

Commit 1baf67d

Browse files
committed
Auto merge of rust-lang#116125 - RalfJung:const-param-ty-eq, r=compiler-errors
ConstParamTy: require Eq as supertrait As discussed with `@BoxyUwu` [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/.60ConstParamTy.60.20and.20.60Eq.60). We want to say that valtree equality on const generic params agrees with `==`, but that only makes sense if `==` actually exists, hence we should have an appropriate bound. Valtree equality is an equivalence relation, so such a type can always be `Eq` and not just `PartialEq`.
2 parents 63c765a + f6b2be5 commit 1baf67d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

core/src/marker.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,11 +986,16 @@ pub trait Tuple {}
986986
pub trait PointerLike {}
987987

988988
/// A marker for types which can be used as types of `const` generic parameters.
989+
///
990+
/// These types must have a proper equivalence relation (`Eq`) and it must be automatically
991+
/// derived (`StructuralPartialEq`). There's a hard-coded check in the compiler ensuring
992+
/// that all fields are also `ConstParamTy`, which implies that recursively, all fields
993+
/// are `StructuralPartialEq`.
989994
#[lang = "const_param_ty"]
990995
#[unstable(feature = "adt_const_params", issue = "95174")]
991996
#[rustc_on_unimplemented(message = "`{Self}` can't be used as a const parameter type")]
992997
#[allow(multiple_supertrait_upcastable)]
993-
pub trait ConstParamTy: StructuralEq + StructuralPartialEq {}
998+
pub trait ConstParamTy: StructuralEq + StructuralPartialEq + Eq {}
994999

9951000
/// Derive macro generating an impl of the trait `ConstParamTy`.
9961001
#[rustc_builtin_macro]

0 commit comments

Comments
 (0)