@@ -62,17 +62,13 @@ impl<'a, T> PartialEq for Interned<'a, T> {
62
62
63
63
impl < ' a , T > Eq for Interned < ' a , T > { }
64
64
65
- impl < ' a , T : PartialOrd > PartialOrd for Interned < ' a , T > {
65
+ // In practice you can't intern any `T` that doesn't implement `Eq`, because
66
+ // that's needed for hashing. Therefore, we won't be interning any `T` that
67
+ // implements `PartialOrd` without also implementing `Ord`. So we can have the
68
+ // bound `T: Ord` here and avoid duplication with the `Ord` impl below.
69
+ impl < ' a , T : Ord > PartialOrd for Interned < ' a , T > {
66
70
fn partial_cmp ( & self , other : & Interned < ' a , T > ) -> Option < Ordering > {
67
- // Pointer equality implies equality, due to the uniqueness constraint,
68
- // but the contents must be compared otherwise.
69
- if ptr:: eq ( self . 0 , other. 0 ) {
70
- Some ( Ordering :: Equal )
71
- } else {
72
- let res = self . 0 . partial_cmp ( & other. 0 ) ;
73
- debug_assert ! ( res != Some ( Ordering :: Equal ) ) ;
74
- res
75
- }
71
+ Some ( self . cmp ( other) )
76
72
}
77
73
}
78
74
@@ -84,7 +80,7 @@ impl<'a, T: Ord> Ord for Interned<'a, T> {
84
80
Ordering :: Equal
85
81
} else {
86
82
let res = self . 0 . cmp ( & other. 0 ) ;
87
- debug_assert ! ( res != Ordering :: Equal ) ;
83
+ debug_assert_ne ! ( res, Ordering :: Equal ) ;
88
84
res
89
85
}
90
86
}
0 commit comments