@@ -120,7 +120,9 @@ pub enum AliasKind {
120
120
PartialOrd = "feature_allow_slow_enum" ,
121
121
Ord ( bound = "" ) ,
122
122
Ord = "feature_allow_slow_enum" ,
123
- Hash ( bound = "" )
123
+ Hash ( bound = "" ) ,
124
+ PartialEq ( bound = "" ) ,
125
+ Eq ( bound = "" )
124
126
) ]
125
127
pub enum TyKind < I : Interner > {
126
128
/// The primitive boolean type. Written as `bool`.
@@ -332,58 +334,6 @@ const fn tykind_discriminant<I: Interner>(value: &TyKind<I>) -> usize {
332
334
}
333
335
}
334
336
335
- // This is manually implemented because a derive would require `I: PartialEq`
336
- impl < I : Interner > PartialEq for TyKind < I > {
337
- #[ inline]
338
- fn eq ( & self , other : & TyKind < I > ) -> bool {
339
- // You might expect this `match` to be preceded with this:
340
- //
341
- // tykind_discriminant(self) == tykind_discriminant(other) &&
342
- //
343
- // but the data patterns in practice are such that a comparison
344
- // succeeds 99%+ of the time, and it's faster to omit it.
345
- match ( self , other) {
346
- ( Int ( a_i) , Int ( b_i) ) => a_i == b_i,
347
- ( Uint ( a_u) , Uint ( b_u) ) => a_u == b_u,
348
- ( Float ( a_f) , Float ( b_f) ) => a_f == b_f,
349
- ( Adt ( a_d, a_s) , Adt ( b_d, b_s) ) => a_d == b_d && a_s == b_s,
350
- ( Foreign ( a_d) , Foreign ( b_d) ) => a_d == b_d,
351
- ( Array ( a_t, a_c) , Array ( b_t, b_c) ) => a_t == b_t && a_c == b_c,
352
- ( Slice ( a_t) , Slice ( b_t) ) => a_t == b_t,
353
- ( RawPtr ( a_t) , RawPtr ( b_t) ) => a_t == b_t,
354
- ( Ref ( a_r, a_t, a_m) , Ref ( b_r, b_t, b_m) ) => a_r == b_r && a_t == b_t && a_m == b_m,
355
- ( FnDef ( a_d, a_s) , FnDef ( b_d, b_s) ) => a_d == b_d && a_s == b_s,
356
- ( FnPtr ( a_s) , FnPtr ( b_s) ) => a_s == b_s,
357
- ( Dynamic ( a_p, a_r, a_repr) , Dynamic ( b_p, b_r, b_repr) ) => {
358
- a_p == b_p && a_r == b_r && a_repr == b_repr
359
- }
360
- ( Closure ( a_d, a_s) , Closure ( b_d, b_s) ) => a_d == b_d && a_s == b_s,
361
- ( Coroutine ( a_d, a_s, a_m) , Coroutine ( b_d, b_s, b_m) ) => {
362
- a_d == b_d && a_s == b_s && a_m == b_m
363
- }
364
- ( CoroutineWitness ( a_d, a_s) , CoroutineWitness ( b_d, b_s) ) => a_d == b_d && a_s == b_s,
365
- ( Tuple ( a_t) , Tuple ( b_t) ) => a_t == b_t,
366
- ( Alias ( a_i, a_p) , Alias ( b_i, b_p) ) => a_i == b_i && a_p == b_p,
367
- ( Param ( a_p) , Param ( b_p) ) => a_p == b_p,
368
- ( Bound ( a_d, a_b) , Bound ( b_d, b_b) ) => a_d == b_d && a_b == b_b,
369
- ( Placeholder ( a_p) , Placeholder ( b_p) ) => a_p == b_p,
370
- ( Infer ( a_t) , Infer ( b_t) ) => a_t == b_t,
371
- ( Error ( a_e) , Error ( b_e) ) => a_e == b_e,
372
- ( Bool , Bool ) | ( Char , Char ) | ( Str , Str ) | ( Never , Never ) => true ,
373
- _ => {
374
- debug_assert ! (
375
- tykind_discriminant( self ) != tykind_discriminant( other) ,
376
- "This branch must be unreachable, maybe the match is missing an arm? self = self = {self:?}, other = {other:?}"
377
- ) ;
378
- false
379
- }
380
- }
381
- }
382
- }
383
-
384
- // This is manually implemented because a derive would require `I: Eq`
385
- impl < I : Interner > Eq for TyKind < I > { }
386
-
387
337
impl < I : Interner > DebugWithInfcx < I > for TyKind < I > {
388
338
fn fmt < Infcx : InferCtxtLike < Interner = I > > (
389
339
this : WithInfcx < ' _ , Infcx , & Self > ,
0 commit comments