File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: def_id:: { LocalDefId , CRATE_DEF_INDEX } ;
2
+ use std:: cmp:: Ordering ;
2
3
use std:: fmt;
3
4
4
5
/// Uniquely identifies a node in the HIR of the current crate. It is
@@ -18,6 +19,22 @@ pub struct HirId {
18
19
pub local_id : ItemLocalId ,
19
20
}
20
21
22
+ impl Ord for HirId {
23
+ fn cmp ( & self , other : & Self ) -> Ordering {
24
+ ( self . owner . local_def_index , self . local_id )
25
+ . cmp ( & ( other. owner . local_def_index , other. local_id ) )
26
+ }
27
+ }
28
+
29
+ impl PartialOrd for HirId {
30
+ fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
31
+ Some (
32
+ ( self . owner . local_def_index , self . local_id )
33
+ . cmp ( & ( other. owner . local_def_index , other. local_id ) ) ,
34
+ )
35
+ }
36
+ }
37
+
21
38
impl HirId {
22
39
pub fn expect_owner ( self ) -> LocalDefId {
23
40
assert_eq ! ( self . local_id. index( ) , 0 ) ;
You can’t perform that action at this time.
0 commit comments