@@ -196,12 +196,19 @@ pub struct AssociatedType {
196196 pub container : ImplOrTraitItemContainer ,
197197}
198198
199- #[ deriving( Clone , PartialEq , Eq , Hash , Show ) ]
199+ #[ deriving( Clone , Eq , Hash , Show ) ]
200200pub struct mt < ' tcx > {
201201 pub ty : Ty < ' tcx > ,
202202 pub mutbl : ast:: Mutability ,
203203}
204204
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+
205212#[ deriving( Clone , PartialEq , Eq , Hash , Encodable , Decodable , Show ) ]
206213pub enum TraitStore {
207214 /// Box<Trait>
@@ -254,7 +261,7 @@ pub enum AutoAdjustment<'tcx> {
254261 AdjustDerefRef ( AutoDerefRef < ' tcx > )
255262}
256263
257- #[ deriving( Clone , PartialEq , Show ) ]
264+ #[ deriving( Clone , Show ) ]
258265pub enum UnsizeKind < ' tcx > {
259266 // [T, ..n] -> [T], the uint field is n.
260267 UnsizeLength ( uint ) ,
@@ -264,6 +271,22 @@ pub enum UnsizeKind<'tcx> {
264271 UnsizeVtable ( TyTrait < ' tcx > , /* the self type of the trait */ Ty < ' tcx > )
265272}
266273
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+
267290#[ deriving( Clone , Show ) ]
268291pub struct AutoDerefRef < ' tcx > {
269292 pub autoderefs : uint ,
@@ -603,7 +626,7 @@ impl<'tcx, S: Writer> Hash<S> for TyS<'tcx> {
603626pub type Ty < ' tcx > = & ' tcx TyS < ' tcx > ;
604627
605628/// An entry in the type interner.
606- struct InternedTy < ' tcx > {
629+ pub struct InternedTy < ' tcx > {
607630 ty : Ty < ' tcx >
608631}
609632
@@ -666,12 +689,23 @@ pub struct ClosureTy<'tcx> {
666689 pub abi : abi:: Abi ,
667690}
668691
669- #[ deriving( Clone , PartialEq , Eq , Hash ) ]
692+ #[ deriving( Clone , Eq , Hash ) ]
670693pub enum FnOutput < ' tcx > {
671694 FnConverging ( Ty < ' tcx > ) ,
672695 FnDiverging
673696}
674697
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+
675709impl < ' tcx > FnOutput < ' tcx > {
676710 pub fn unwrap ( self ) -> Ty < ' tcx > {
677711 match self {
@@ -693,14 +727,25 @@ impl<'tcx> FnOutput<'tcx> {
693727 * - `output` is the return type.
694728 * - `variadic` indicates whether this is a varidic function. (only true for foreign fns)
695729 */
696- #[ deriving( Clone , PartialEq , Eq , Hash ) ]
730+ #[ deriving( Clone , Eq , Hash ) ]
697731pub struct FnSig < ' tcx > {
698732 pub binder_id : ast:: NodeId ,
699733 pub inputs : Vec < Ty < ' tcx > > ,
700734 pub output : FnOutput < ' tcx > ,
701735 pub variadic : bool
702736}
703737
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+
704749#[ deriving( Clone , PartialEq , Eq , Hash , Show ) ]
705750pub struct ParamTy {
706751 pub space : subst:: ParamSpace ,
@@ -939,7 +984,7 @@ mod primitives {
939984
940985// NB: If you change this, you'll probably want to change the corresponding
941986// AST structure in libsyntax/ast.rs as well.
942- #[ deriving( Clone , PartialEq , Eq , Hash , Show ) ]
987+ #[ deriving( Clone , Eq , Hash , Show ) ]
943988pub enum sty < ' tcx > {
944989 ty_nil,
945990 ty_bool,
@@ -980,6 +1025,46 @@ pub enum sty<'tcx> {
9801025 // on non-useful type error messages)
9811026}
9821027
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+
9831068#[ deriving( Clone , PartialEq , Eq , Hash , Show ) ]
9841069pub struct TyTrait < ' tcx > {
9851070 pub def_id : DefId ,
0 commit comments