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 11use crate :: def_id:: { LocalDefId , CRATE_DEF_INDEX } ;
2+ use std:: cmp:: Ordering ;
23use std:: fmt;
34
45/// Uniquely identifies a node in the HIR of the current crate. It is
@@ -18,6 +19,22 @@ pub struct HirId {
1819 pub local_id : ItemLocalId ,
1920}
2021
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+
2138impl HirId {
2239 pub fn expect_owner ( self ) -> LocalDefId {
2340 assert_eq ! ( self . local_id. index( ) , 0 ) ;
You can’t perform that action at this time.
0 commit comments