@@ -39,6 +39,7 @@ use util::nodemap::{NodeSet, DefIdMap, FxHashMap, FxHashSet};
3939use serialize:: { self , Encodable , Encoder } ;
4040use std:: collections:: BTreeMap ;
4141use std:: cmp;
42+ use std:: cmp:: Ordering ;
4243use std:: fmt;
4344use std:: hash:: { Hash , Hasher } ;
4445use std:: iter:: FromIterator ;
@@ -497,6 +498,20 @@ impl<'tcx> Hash for TyS<'tcx> {
497498 }
498499}
499500
501+ impl < ' tcx > Ord for TyS < ' tcx > {
502+ #[ inline]
503+ fn cmp ( & self , other : & TyS < ' tcx > ) -> Ordering {
504+ // (self as *const _).cmp(other as *const _)
505+ ( self as * const TyS < ' tcx > ) . cmp ( & ( other as * const TyS < ' tcx > ) )
506+ }
507+ }
508+ impl < ' tcx > PartialOrd for TyS < ' tcx > {
509+ #[ inline]
510+ fn partial_cmp ( & self , other : & TyS < ' tcx > ) -> Option < Ordering > {
511+ Some ( self . cmp ( other) )
512+ }
513+ }
514+
500515impl < ' tcx > TyS < ' tcx > {
501516 pub fn is_primitive_ty ( & self ) -> bool {
502517 match self . sty {
@@ -566,6 +581,19 @@ impl<T> PartialEq for Slice<T> {
566581}
567582impl < T > Eq for Slice < T > { }
568583
584+ impl < T > Ord for Slice < T > {
585+ #[ inline]
586+ fn cmp ( & self , other : & Slice < T > ) -> Ordering {
587+ ( & self . 0 as * const [ T ] ) . cmp ( & ( & other. 0 as * const [ T ] ) )
588+ }
589+ }
590+ impl < T > PartialOrd for Slice < T > {
591+ #[ inline]
592+ fn partial_cmp ( & self , other : & Slice < T > ) -> Option < Ordering > {
593+ Some ( self . cmp ( other) )
594+ }
595+ }
596+
569597impl < T > Hash for Slice < T > {
570598 fn hash < H : Hasher > ( & self , s : & mut H ) {
571599 ( self . as_ptr ( ) , self . len ( ) ) . hash ( s)
@@ -1101,7 +1129,7 @@ pub type PolySubtypePredicate<'tcx> = ty::Binder<SubtypePredicate<'tcx>>;
11011129/// equality between arbitrary types. Processing an instance of
11021130/// Form #2 eventually yields one of these `ProjectionPredicate`
11031131/// instances to normalize the LHS.
1104- #[ derive( Copy , Clone , PartialEq , Eq , Hash , RustcEncodable , RustcDecodable ) ]
1132+ #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , RustcEncodable , RustcDecodable ) ]
11051133pub struct ProjectionPredicate < ' tcx > {
11061134 pub projection_ty : ProjectionTy < ' tcx > ,
11071135 pub ty : Ty < ' tcx > ,
0 commit comments