@@ -39,6 +39,7 @@ use util::nodemap::{NodeSet, DefIdMap, FxHashMap, FxHashSet};
39
39
use serialize:: { self , Encodable , Encoder } ;
40
40
use std:: collections:: BTreeMap ;
41
41
use std:: cmp;
42
+ use std:: cmp:: Ordering ;
42
43
use std:: fmt;
43
44
use std:: hash:: { Hash , Hasher } ;
44
45
use std:: iter:: FromIterator ;
@@ -497,6 +498,20 @@ impl<'tcx> Hash for TyS<'tcx> {
497
498
}
498
499
}
499
500
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
+
500
515
impl < ' tcx > TyS < ' tcx > {
501
516
pub fn is_primitive_ty ( & self ) -> bool {
502
517
match self . sty {
@@ -566,6 +581,19 @@ impl<T> PartialEq for Slice<T> {
566
581
}
567
582
impl < T > Eq for Slice < T > { }
568
583
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
+
569
597
impl < T > Hash for Slice < T > {
570
598
fn hash < H : Hasher > ( & self , s : & mut H ) {
571
599
( self . as_ptr ( ) , self . len ( ) ) . hash ( s)
@@ -1101,7 +1129,7 @@ pub type PolySubtypePredicate<'tcx> = ty::Binder<SubtypePredicate<'tcx>>;
1101
1129
/// equality between arbitrary types. Processing an instance of
1102
1130
/// Form #2 eventually yields one of these `ProjectionPredicate`
1103
1131
/// 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 ) ]
1105
1133
pub struct ProjectionPredicate < ' tcx > {
1106
1134
pub projection_ty : ProjectionTy < ' tcx > ,
1107
1135
pub ty : Ty < ' tcx > ,
0 commit comments