@@ -225,77 +225,6 @@ marker_impls! {
225
225
{ T : ?Sized } & T ,
226
226
}
227
227
228
- /// Required trait for constants used in pattern matches.
229
- ///
230
- /// Any type that derives `Eq` automatically implements this trait, *regardless*
231
- /// of whether its type parameters implement `Eq`.
232
- ///
233
- /// This is a hack to work around a limitation in our type system.
234
- ///
235
- /// # Background
236
- ///
237
- /// We want to require that types of consts used in pattern matches
238
- /// have the attribute `#[derive(PartialEq, Eq)]`.
239
- ///
240
- /// In a more ideal world, we could check that requirement by just checking that
241
- /// the given type implements both the `StructuralPartialEq` trait *and*
242
- /// the `Eq` trait. However, you can have ADTs that *do* `derive(PartialEq, Eq)`,
243
- /// and be a case that we want the compiler to accept, and yet the constant's
244
- /// type fails to implement `Eq`.
245
- ///
246
- /// Namely, a case like this:
247
- ///
248
- /// ```rust
249
- /// #[derive(PartialEq, Eq)]
250
- /// struct Wrap<X>(X);
251
- ///
252
- /// fn higher_order(_: &()) { }
253
- ///
254
- /// const CFN: Wrap<fn(&())> = Wrap(higher_order);
255
- ///
256
- /// #[allow(pointer_structural_match)]
257
- /// fn main() {
258
- /// match CFN {
259
- /// CFN => {}
260
- /// _ => {}
261
- /// }
262
- /// }
263
- /// ```
264
- ///
265
- /// (The problem in the above code is that `Wrap<fn(&())>` does not implement
266
- /// `PartialEq`, nor `Eq`, because `for<'a> fn(&'a _)` does not implement those
267
- /// traits.)
268
- ///
269
- /// Therefore, we cannot rely on naive check for `StructuralPartialEq` and
270
- /// mere `Eq`.
271
- ///
272
- /// As a hack to work around this, we use two separate traits injected by each
273
- /// of the two derives (`#[derive(PartialEq)]` and `#[derive(Eq)]`) and check
274
- /// that both of them are present as part of structural-match checking.
275
- #[ unstable( feature = "structural_match" , issue = "31434" ) ]
276
- #[ diagnostic:: on_unimplemented( message = "the type `{Self}` does not `#[derive(Eq)]`" ) ]
277
- #[ lang = "structural_teq" ]
278
- #[ cfg( bootstrap) ]
279
- pub trait StructuralEq {
280
- // Empty.
281
- }
282
-
283
- // FIXME: Remove special cases of these types from the compiler pattern checking code and always check `T: StructuralEq` instead
284
- marker_impls ! {
285
- #[ unstable( feature = "structural_match" , issue = "31434" ) ]
286
- #[ cfg( bootstrap) ]
287
- StructuralEq for
288
- usize , u8 , u16 , u32 , u64 , u128 ,
289
- isize , i8 , i16 , i32 , i64 , i128 ,
290
- bool ,
291
- char ,
292
- str /* Technically requires `[u8]: StructuralEq` */ ,
293
- ( ) ,
294
- { T , const N : usize } [ T ; N ] ,
295
- { T } [ T ] ,
296
- { T : ?Sized } & T ,
297
- }
298
-
299
228
/// Types whose values can be duplicated simply by copying bits.
300
229
///
301
230
/// By default, variable bindings have 'move semantics.' In other
@@ -860,10 +789,6 @@ impl<T: ?Sized> Default for PhantomData<T> {
860
789
#[ unstable( feature = "structural_match" , issue = "31434" ) ]
861
790
impl < T : ?Sized > StructuralPartialEq for PhantomData < T > { }
862
791
863
- #[ unstable( feature = "structural_match" , issue = "31434" ) ]
864
- #[ cfg( bootstrap) ]
865
- impl < T : ?Sized > StructuralEq for PhantomData < T > { }
866
-
867
792
/// Compiler-internal trait used to indicate the type of enum discriminants.
868
793
///
869
794
/// This trait is automatically implemented for every type and does not add any
@@ -1041,22 +966,8 @@ pub trait PointerLike {}
1041
966
#[ unstable( feature = "adt_const_params" , issue = "95174" ) ]
1042
967
#[ diagnostic:: on_unimplemented( message = "`{Self}` can't be used as a const parameter type" ) ]
1043
968
#[ allow( multiple_supertrait_upcastable) ]
1044
- #[ cfg( not( bootstrap) ) ]
1045
969
pub trait ConstParamTy : StructuralPartialEq + Eq { }
1046
970
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) ]
1058
- pub trait ConstParamTy : StructuralEq + StructuralPartialEq + Eq { }
1059
-
1060
971
/// Derive macro generating an impl of the trait `ConstParamTy`.
1061
972
#[ rustc_builtin_macro]
1062
973
#[ unstable( feature = "adt_const_params" , issue = "95174" ) ]
0 commit comments