@@ -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 ,
@@ -603,7 +626,7 @@ impl<'tcx, S: Writer> Hash<S> for TyS<'tcx> {
603
626
pub type Ty < ' tcx > = & ' tcx TyS < ' tcx > ;
604
627
605
628
/// An entry in the type interner.
606
- struct InternedTy < ' tcx > {
629
+ pub struct InternedTy < ' tcx > {
607
630
ty : Ty < ' tcx >
608
631
}
609
632
@@ -666,12 +689,23 @@ pub struct ClosureTy<'tcx> {
666
689
pub abi : abi:: Abi ,
667
690
}
668
691
669
- #[ deriving( Clone , PartialEq , Eq , Hash ) ]
692
+ #[ deriving( Clone , Eq , Hash ) ]
670
693
pub enum FnOutput < ' tcx > {
671
694
FnConverging ( Ty < ' tcx > ) ,
672
695
FnDiverging
673
696
}
674
697
698
+ // FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
699
+ impl < ' tcx > PartialEq for FnOutput < ' tcx > {
700
+ fn eq ( & self , other : & FnOutput < ' tcx > ) -> bool {
701
+ match ( * self , * other) {
702
+ ( FnConverging ( a) , FnConverging ( b) ) => a == b,
703
+ ( FnDiverging , FnDiverging ) => true ,
704
+ _ => false
705
+ }
706
+ }
707
+ }
708
+
675
709
impl < ' tcx > FnOutput < ' tcx > {
676
710
pub fn unwrap ( self ) -> Ty < ' tcx > {
677
711
match self {
@@ -693,14 +727,25 @@ impl<'tcx> FnOutput<'tcx> {
693
727
* - `output` is the return type.
694
728
* - `variadic` indicates whether this is a varidic function. (only true for foreign fns)
695
729
*/
696
- #[ deriving( Clone , PartialEq , Eq , Hash ) ]
730
+ #[ deriving( Clone , Eq , Hash ) ]
697
731
pub struct FnSig < ' tcx > {
698
732
pub binder_id : ast:: NodeId ,
699
733
pub inputs : Vec < Ty < ' tcx > > ,
700
734
pub output : FnOutput < ' tcx > ,
701
735
pub variadic : bool
702
736
}
703
737
738
+ // FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
739
+ impl < ' tcx > PartialEq for FnSig < ' tcx > {
740
+ fn eq ( & self , other : & FnSig < ' tcx > ) -> bool {
741
+ let ( a, b) = ( self , other) ;
742
+ a. binder_id == b. binder_id &&
743
+ a. inputs == b. inputs &&
744
+ a. output == b. output &&
745
+ a. variadic == b. variadic
746
+ }
747
+ }
748
+
704
749
#[ deriving( Clone , PartialEq , Eq , Hash , Show ) ]
705
750
pub struct ParamTy {
706
751
pub space : subst:: ParamSpace ,
@@ -939,7 +984,7 @@ mod primitives {
939
984
940
985
// NB: If you change this, you'll probably want to change the corresponding
941
986
// AST structure in libsyntax/ast.rs as well.
942
- #[ deriving( Clone , PartialEq , Eq , Hash , Show ) ]
987
+ #[ deriving( Clone , Eq , Hash , Show ) ]
943
988
pub enum sty < ' tcx > {
944
989
ty_nil,
945
990
ty_bool,
@@ -980,6 +1025,46 @@ pub enum sty<'tcx> {
980
1025
// on non-useful type error messages)
981
1026
}
982
1027
1028
+ // FIXME(#15689) #[deriving(PartialEq)] fails with Ty (&TyS) because of method lookup.
1029
+ impl < ' tcx > PartialEq for sty < ' tcx > {
1030
+ fn eq ( & self , other : & sty < ' tcx > ) -> bool {
1031
+ match ( self , other) {
1032
+ ( & ty_nil, & ty_nil) |
1033
+ ( & ty_bool, & ty_bool) |
1034
+ ( & ty_char, & ty_char) |
1035
+ ( & ty_str, & ty_str) |
1036
+ ( & ty_err, & ty_err) => true ,
1037
+ ( & ty_int( a) , & ty_int( b) ) => a == b,
1038
+ ( & ty_uint( a) , & ty_uint( b) ) => a == b,
1039
+ ( & ty_float( a) , & ty_float( b) ) => a == b,
1040
+ ( & ty_uniq( a) , & ty_uniq( b) ) |
1041
+ ( & ty_open( a) , & ty_open( b) ) => a == b,
1042
+ ( & ty_enum( a_def, ref a_substs) , & ty_enum( b_def, ref b_substs) ) |
1043
+ ( & ty_struct( a_def, ref a_substs) , & ty_struct( b_def, ref b_substs) ) => {
1044
+ a_def == b_def && a_substs == b_substs
1045
+ }
1046
+ ( & ty_vec( a_ty, a_len) , & ty_vec( b_ty, b_len) ) => {
1047
+ a_ty == b_ty && a_len == b_len
1048
+ }
1049
+ ( & ty_ptr( a) , & ty_ptr( b) ) => a == b,
1050
+ ( & ty_rptr( a_lt, a_ty) , & ty_rptr( b_lt, b_ty) ) => {
1051
+ a_lt == b_lt && a_ty == b_ty
1052
+ }
1053
+ ( & ty_bare_fn( ref a) , & ty_bare_fn( ref b) ) => a == b,
1054
+ ( & ty_closure( ref a) , & ty_closure( ref b) ) => a == b,
1055
+ ( & ty_trait( ref a) , & ty_trait( ref b) ) => a == b,
1056
+ ( & ty_unboxed_closure( a_def, a_lt, ref a_substs) ,
1057
+ & ty_unboxed_closure( b_def, b_lt, ref b_substs) ) => {
1058
+ a_def == b_def && a_lt == b_lt && a_substs == b_substs
1059
+ }
1060
+ ( & ty_tup( ref a) , & ty_tup( ref b) ) => a == b,
1061
+ ( & ty_param( a) , & ty_param( b) ) => a == b,
1062
+ ( & ty_infer( a) , & ty_infer( b) ) => a == b,
1063
+ _ => false
1064
+ }
1065
+ }
1066
+ }
1067
+
983
1068
#[ deriving( Clone , PartialEq , Eq , Hash , Show ) ]
984
1069
pub struct TyTrait < ' tcx > {
985
1070
pub def_id : DefId ,
0 commit comments