@@ -187,7 +187,7 @@ pub trait Unsize<T: ?Sized> {
187
187
/// Required trait for constants used in pattern matches.
188
188
///
189
189
/// 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 `.
191
191
///
192
192
/// If a `const` item contains some type that does not implement this trait,
193
193
/// then that type either (1.) does not implement `PartialEq` (which means the
@@ -200,7 +200,7 @@ pub trait Unsize<T: ?Sized> {
200
200
/// a pattern match.
201
201
///
202
202
/// 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.
204
204
///
205
205
/// [RFC1445]: https://github.com/rust-lang/rfcs/blob/master/text/1445-restrict-constants-in-patterns.md
206
206
/// [issue 63438]: https://github.com/rust-lang/rust/issues/63438
@@ -218,7 +218,7 @@ marker_impls! {
218
218
isize , i8 , i16 , i32 , i64 , i128 ,
219
219
bool ,
220
220
char ,
221
- str /* Technically requires `[u8]: StructuralEq ` */ ,
221
+ str /* Technically requires `[u8]: StructuralPartialEq ` */ ,
222
222
( ) ,
223
223
{ T , const N : usize } [ T ; N ] ,
224
224
{ T } [ T ] ,
@@ -275,13 +275,15 @@ marker_impls! {
275
275
#[ unstable( feature = "structural_match" , issue = "31434" ) ]
276
276
#[ diagnostic:: on_unimplemented( message = "the type `{Self}` does not `#[derive(Eq)]`" ) ]
277
277
#[ lang = "structural_teq" ]
278
+ #[ cfg( bootstrap) ]
278
279
pub trait StructuralEq {
279
280
// Empty.
280
281
}
281
282
282
283
// FIXME: Remove special cases of these types from the compiler pattern checking code and always check `T: StructuralEq` instead
283
284
marker_impls ! {
284
285
#[ unstable( feature = "structural_match" , issue = "31434" ) ]
286
+ #[ cfg( bootstrap) ]
285
287
StructuralEq for
286
288
usize , u8 , u16 , u32 , u64 , u128 ,
287
289
isize , i8 , i16 , i32 , i64 , i128 ,
@@ -859,6 +861,7 @@ impl<T: ?Sized> Default for PhantomData<T> {
859
861
impl < T : ?Sized > StructuralPartialEq for PhantomData < T > { }
860
862
861
863
#[ unstable( feature = "structural_match" , issue = "31434" ) ]
864
+ #[ cfg( bootstrap) ]
862
865
impl < T : ?Sized > StructuralEq for PhantomData < T > { }
863
866
864
867
/// Compiler-internal trait used to indicate the type of enum discriminants.
@@ -1038,6 +1041,20 @@ pub trait PointerLike {}
1038
1041
#[ unstable( feature = "adt_const_params" , issue = "95174" ) ]
1039
1042
#[ diagnostic:: on_unimplemented( message = "`{Self}` can't be used as a const parameter type" ) ]
1040
1043
#[ 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) ]
1041
1058
pub trait ConstParamTy : StructuralEq + StructuralPartialEq + Eq { }
1042
1059
1043
1060
/// Derive macro generating an impl of the trait `ConstParamTy`.
0 commit comments