@@ -196,12 +196,19 @@ pub struct AssociatedType {
196
196
pub container : ImplOrTraitItemContainer ,
197
197
}
198
198
199
- #[ deriving( Clone , PartialEq , Eq , Hash , Show ) ]
199
+ #[ deriving( Clone , Eq , Hash , Show ) ]
200
200
pub struct mt < ' tcx > {
201
201
pub ty : Ty < ' tcx > ,
202
202
pub mutbl : ast:: Mutability ,
203
203
}
204
204
205
+ // FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
206
+ impl < ' tcx > PartialEq for mt < ' tcx > {
207
+ fn eq ( & self , other : & mt < ' tcx > ) -> bool {
208
+ self . ty == other. ty && self . mutbl == other. mutbl
209
+ }
210
+ }
211
+
205
212
#[ deriving( Clone , PartialEq , Eq , Hash , Encodable , Decodable , Show ) ]
206
213
pub enum TraitStore {
207
214
/// Box<Trait>
@@ -254,7 +261,7 @@ pub enum AutoAdjustment<'tcx> {
254
261
AdjustDerefRef ( AutoDerefRef < ' tcx > )
255
262
}
256
263
257
- #[ deriving( Clone , PartialEq , Show ) ]
264
+ #[ deriving( Clone , Show ) ]
258
265
pub enum UnsizeKind < ' tcx > {
259
266
// [T, ..n] -> [T], the uint field is n.
260
267
UnsizeLength ( uint ) ,
@@ -264,6 +271,22 @@ pub enum UnsizeKind<'tcx> {
264
271
UnsizeVtable ( TyTrait < ' tcx > , /* the self type of the trait */ Ty < ' tcx > )
265
272
}
266
273
274
+ // FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
275
+ impl < ' tcx > PartialEq for UnsizeKind < ' tcx > {
276
+ fn eq ( & self , other : & UnsizeKind < ' tcx > ) -> bool {
277
+ match ( self , other) {
278
+ ( & UnsizeLength ( a) , & UnsizeLength ( b) ) => a == b,
279
+ ( & UnsizeStruct ( ref a_kind, a_idx) , & UnsizeStruct ( ref b_kind, b_idx) ) => {
280
+ a_kind == b_kind && a_idx == b_idx
281
+ }
282
+ ( & UnsizeVtable ( ref a_trait, a_self) , & UnsizeVtable ( ref b_trait, b_self) ) => {
283
+ a_trait == b_trait && a_self == b_self
284
+ }
285
+ _ => false
286
+ }
287
+ }
288
+ }
289
+
267
290
#[ deriving( Clone , Show ) ]
268
291
pub struct AutoDerefRef < ' tcx > {
269
292
pub autoderefs : uint ,
@@ -607,7 +630,7 @@ impl<'tcx, S: Writer> Hash<S> for TyS<'tcx> {
607
630
pub type Ty < ' tcx > = & ' tcx TyS < ' tcx > ;
608
631
609
632
/// An entry in the type interner.
610
- struct InternedTy < ' tcx > {
633
+ pub struct InternedTy < ' tcx > {
611
634
ty : Ty < ' tcx >
612
635
}
613
636
@@ -670,12 +693,23 @@ pub struct ClosureTy<'tcx> {
670
693
pub abi : abi:: Abi ,
671
694
}
672
695
673
- #[ deriving( Clone , PartialEq , Eq , Hash ) ]
696
+ #[ deriving( Clone , Eq , Hash ) ]
674
697
pub enum FnOutput < ' tcx > {
675
698
FnConverging ( Ty < ' tcx > ) ,
676
699
FnDiverging
677
700
}
678
701
702
+ // FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
703
+ impl < ' tcx > PartialEq for FnOutput < ' tcx > {
704
+ fn eq ( & self , other : & FnOutput < ' tcx > ) -> bool {
705
+ match ( * self , * other) {
706
+ ( FnConverging ( a) , FnConverging ( b) ) => a == b,
707
+ ( FnDiverging , FnDiverging ) => true ,
708
+ _ => false
709
+ }
710
+ }
711
+ }
712
+
679
713
impl < ' tcx > FnOutput < ' tcx > {
680
714
pub fn unwrap ( self ) -> Ty < ' tcx > {
681
715
match self {
@@ -697,14 +731,25 @@ impl<'tcx> FnOutput<'tcx> {
697
731
* - `output` is the return type.
698
732
* - `variadic` indicates whether this is a varidic function. (only true for foreign fns)
699
733
*/
700
- #[ deriving( Clone , PartialEq , Eq , Hash ) ]
734
+ #[ deriving( Clone , Eq , Hash ) ]
701
735
pub struct FnSig < ' tcx > {
702
736
pub binder_id : ast:: NodeId ,
703
737
pub inputs : Vec < Ty < ' tcx > > ,
704
738
pub output : FnOutput < ' tcx > ,
705
739
pub variadic : bool
706
740
}
707
741
742
+ // FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
743
+ impl < ' tcx > PartialEq for FnSig < ' tcx > {
744
+ fn eq ( & self , other : & FnSig < ' tcx > ) -> bool {
745
+ let ( a, b) = ( self , other) ;
746
+ a. binder_id == b. binder_id &&
747
+ a. inputs == b. inputs &&
748
+ a. output == b. output &&
749
+ a. variadic == b. variadic
750
+ }
751
+ }
752
+
708
753
#[ deriving( Clone , PartialEq , Eq , Hash , Show ) ]
709
754
pub struct ParamTy {
710
755
pub space : subst:: ParamSpace ,
@@ -943,7 +988,7 @@ mod primitives {
943
988
944
989
// NB: If you change this, you'll probably want to change the corresponding
945
990
// AST structure in libsyntax/ast.rs as well.
946
- #[ deriving( Clone , PartialEq , Eq , Hash , Show ) ]
991
+ #[ deriving( Clone , Eq , Hash , Show ) ]
947
992
pub enum sty < ' tcx > {
948
993
ty_nil,
949
994
ty_bool,
@@ -984,6 +1029,46 @@ pub enum sty<'tcx> {
984
1029
// on non-useful type error messages)
985
1030
}
986
1031
1032
+ // FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
1033
+ impl < ' tcx > PartialEq for sty < ' tcx > {
1034
+ fn eq ( & self , other : & sty < ' tcx > ) -> bool {
1035
+ match ( self , other) {
1036
+ ( & ty_nil, & ty_nil) |
1037
+ ( & ty_bool, & ty_bool) |
1038
+ ( & ty_char, & ty_char) |
1039
+ ( & ty_str, & ty_str) |
1040
+ ( & ty_err, & ty_err) => true ,
1041
+ ( & ty_int( a) , & ty_int( b) ) => a == b,
1042
+ ( & ty_uint( a) , & ty_uint( b) ) => a == b,
1043
+ ( & ty_float( a) , & ty_float( b) ) => a == b,
1044
+ ( & ty_uniq( a) , & ty_uniq( b) ) |
1045
+ ( & ty_open( a) , & ty_open( b) ) => a == b,
1046
+ ( & ty_enum( a_def, ref a_substs) , & ty_enum( b_def, ref b_substs) ) |
1047
+ ( & ty_struct( a_def, ref a_substs) , & ty_struct( b_def, ref b_substs) ) => {
1048
+ a_def == b_def && a_substs == b_substs
1049
+ }
1050
+ ( & ty_vec( a_ty, a_len) , & ty_vec( b_ty, b_len) ) => {
1051
+ a_ty == b_ty && a_len == b_len
1052
+ }
1053
+ ( & ty_ptr( a) , & ty_ptr( b) ) => a == b,
1054
+ ( & ty_rptr( a_lt, a_ty) , & ty_rptr( b_lt, b_ty) ) => {
1055
+ a_lt == b_lt && a_ty == b_ty
1056
+ }
1057
+ ( & ty_bare_fn( ref a) , & ty_bare_fn( ref b) ) => a == b,
1058
+ ( & ty_closure( ref a) , & ty_closure( ref b) ) => a == b,
1059
+ ( & ty_trait( ref a) , & ty_trait( ref b) ) => a == b,
1060
+ ( & ty_unboxed_closure( a_def, a_lt, ref a_substs) ,
1061
+ & ty_unboxed_closure( b_def, b_lt, ref b_substs) ) => {
1062
+ a_def == b_def && a_lt == b_lt && a_substs == b_substs
1063
+ }
1064
+ ( & ty_tup( ref a) , & ty_tup( ref b) ) => a == b,
1065
+ ( & ty_param( a) , & ty_param( b) ) => a == b,
1066
+ ( & ty_infer( a) , & ty_infer( b) ) => a == b,
1067
+ _ => false
1068
+ }
1069
+ }
1070
+ }
1071
+
987
1072
#[ deriving( Clone , PartialEq , Eq , Hash , Show ) ]
988
1073
pub struct TyTrait < ' tcx > {
989
1074
pub def_id : DefId ,
0 commit comments