@@ -187,7 +187,7 @@ pub trait Unsize<T: ?Sized> {
187187/// Required trait for constants used in pattern matches.
188188///
189189/// Any type that derives `PartialEq` automatically implements this trait,
190- /// *regardless* of whether its type-parameters implement `Eq `.
190+ /// *regardless* of whether its type-parameters implement `PartialEq `.
191191///
192192/// If a `const` item contains some type that does not implement this trait,
193193/// then that type either (1.) does not implement `PartialEq` (which means the
@@ -200,7 +200,7 @@ pub trait Unsize<T: ?Sized> {
200200/// a pattern match.
201201///
202202/// See also the [structural match RFC][RFC1445], and [issue 63438] which
203- /// motivated migrating from attribute-based design to this trait.
203+ /// motivated migrating from an attribute-based design to this trait.
204204///
205205/// [RFC1445]: https://github.com/rust-lang/rfcs/blob/master/text/1445-restrict-constants-in-patterns.md
206206/// [issue 63438]: https://github.com/rust-lang/rust/issues/63438
@@ -218,7 +218,7 @@ marker_impls! {
218218 isize , i8 , i16 , i32 , i64 , i128 ,
219219 bool ,
220220 char ,
221- str /* Technically requires `[u8]: StructuralEq ` */ ,
221+ str /* Technically requires `[u8]: StructuralPartialEq ` */ ,
222222 ( ) ,
223223 { T , const N : usize } [ T ; N ] ,
224224 { T } [ T ] ,
@@ -275,13 +275,15 @@ marker_impls! {
275275#[ unstable( feature = "structural_match" , issue = "31434" ) ]
276276#[ diagnostic:: on_unimplemented( message = "the type `{Self}` does not `#[derive(Eq)]`" ) ]
277277#[ lang = "structural_teq" ]
278+ #[ cfg( bootstrap) ]
278279pub trait StructuralEq {
279280 // Empty.
280281}
281282
282283// FIXME: Remove special cases of these types from the compiler pattern checking code and always check `T: StructuralEq` instead
283284marker_impls ! {
284285 #[ unstable( feature = "structural_match" , issue = "31434" ) ]
286+ #[ cfg( bootstrap) ]
285287 StructuralEq for
286288 usize , u8 , u16 , u32 , u64 , u128 ,
287289 isize , i8 , i16 , i32 , i64 , i128 ,
@@ -859,6 +861,7 @@ impl<T: ?Sized> Default for PhantomData<T> {
859861impl < T : ?Sized > StructuralPartialEq for PhantomData < T > { }
860862
861863#[ unstable( feature = "structural_match" , issue = "31434" ) ]
864+ #[ cfg( bootstrap) ]
862865impl < T : ?Sized > StructuralEq for PhantomData < T > { }
863866
864867/// Compiler-internal trait used to indicate the type of enum discriminants.
@@ -1038,6 +1041,20 @@ pub trait PointerLike {}
10381041#[ unstable( feature = "adt_const_params" , issue = "95174" ) ]
10391042#[ diagnostic:: on_unimplemented( message = "`{Self}` can't be used as a const parameter type" ) ]
10401043#[ allow( multiple_supertrait_upcastable) ]
1044+ #[ cfg( not( bootstrap) ) ]
1045+ pub trait ConstParamTy : StructuralPartialEq + Eq { }
1046+
1047+ /// A marker for types which can be used as types of `const` generic parameters.
1048+ ///
1049+ /// These types must have a proper equivalence relation (`Eq`) and it must be automatically
1050+ /// derived (`StructuralPartialEq`). There's a hard-coded check in the compiler ensuring
1051+ /// that all fields are also `ConstParamTy`, which implies that recursively, all fields
1052+ /// are `StructuralPartialEq`.
1053+ #[ lang = "const_param_ty" ]
1054+ #[ unstable( feature = "adt_const_params" , issue = "95174" ) ]
1055+ #[ rustc_on_unimplemented( message = "`{Self}` can't be used as a const parameter type" ) ]
1056+ #[ allow( multiple_supertrait_upcastable) ]
1057+ #[ cfg( bootstrap) ]
10411058pub trait ConstParamTy : StructuralEq + StructuralPartialEq + Eq { }
10421059
10431060/// Derive macro generating an impl of the trait `ConstParamTy`.
0 commit comments