This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 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 } ;
22use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher , ToStableHashKey } ;
33use rustc_span:: { def_id:: DefPathHash , HashStableContext } ;
44use std:: fmt;
@@ -22,6 +22,18 @@ impl OwnerId {
2222 }
2323}
2424
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+
2537impl < CTX : HashStableContext > HashStable < CTX > for OwnerId {
2638 #[ inline]
2739 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 {
1717
1818 fn index ( self ) -> usize ;
1919
20+ #[ inline]
2021 fn increment_by ( & mut self , amount : usize ) {
2122 * self = self . plus ( amount) ;
2223 }
2324
25+ #[ inline]
2426 fn plus ( self , amount : usize ) -> Self {
2527 Self :: new ( self . index ( ) + amount)
2628 }
You can’t perform that action at this time.
0 commit comments