File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 1
- use crate :: def_id:: { DefId , LocalDefId , CRATE_DEF_ID } ;
1
+ use crate :: def_id:: { DefId , DefIndex , LocalDefId , CRATE_DEF_ID } ;
2
2
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher , ToStableHashKey } ;
3
3
use rustc_span:: { def_id:: DefPathHash , HashStableContext } ;
4
4
use std:: fmt;
@@ -22,6 +22,18 @@ impl OwnerId {
22
22
}
23
23
}
24
24
25
+ impl rustc_index:: vec:: Idx for OwnerId {
26
+ #[ inline]
27
+ fn new ( idx : usize ) -> Self {
28
+ OwnerId { def_id : LocalDefId { local_def_index : DefIndex :: from_usize ( idx) } }
29
+ }
30
+
31
+ #[ inline]
32
+ fn index ( self ) -> usize {
33
+ self . def_id . local_def_index . as_usize ( )
34
+ }
35
+ }
36
+
25
37
impl < CTX : HashStableContext > HashStable < CTX > for OwnerId {
26
38
#[ inline]
27
39
fn hash_stable ( & self , hcx : & mut CTX , hasher : & mut StableHasher ) {
Original file line number Diff line number Diff line change @@ -17,10 +17,12 @@ pub trait Idx: Copy + 'static + Eq + PartialEq + Debug + Hash {
17
17
18
18
fn index ( self ) -> usize ;
19
19
20
+ #[ inline]
20
21
fn increment_by ( & mut self , amount : usize ) {
21
22
* self = self . plus ( amount) ;
22
23
}
23
24
25
+ #[ inline]
24
26
fn plus ( self , amount : usize ) -> Self {
25
27
Self :: new ( self . index ( ) + amount)
26
28
}
You can’t perform that action at this time.
0 commit comments