@@ -27,8 +27,8 @@ use syntax_pos::{Span, DUMMY_SP};
27
27
/// There is one `DefPathTable` for each crate.
28
28
#[ derive( Clone , Default , RustcDecodable , RustcEncodable ) ]
29
29
pub struct DefPathTable {
30
- index_to_key : Vec < DefKey > ,
31
- def_path_hashes : Vec < DefPathHash > ,
30
+ index_to_key : IndexVec < DefIndex , DefKey > ,
31
+ def_path_hashes : IndexVec < DefIndex , DefPathHash > ,
32
32
}
33
33
34
34
impl DefPathTable {
@@ -53,14 +53,14 @@ impl DefPathTable {
53
53
54
54
#[ inline( always) ]
55
55
pub fn def_key ( & self , index : DefIndex ) -> DefKey {
56
- self . index_to_key [ index. index ( ) ]
56
+ self . index_to_key [ index]
57
57
}
58
58
59
59
#[ inline( always) ]
60
60
pub fn def_path_hash ( & self , index : DefIndex ) -> DefPathHash {
61
- let ret = self . def_path_hashes [ index. index ( ) ] ;
62
- debug ! ( "def_path_hash({:?}) = {:?}" , index, ret ) ;
63
- return ret
61
+ let hash = self . def_path_hashes [ index] ;
62
+ debug ! ( "def_path_hash({:?}) = {:?}" , index, hash ) ;
63
+ hash
64
64
}
65
65
66
66
pub fn add_def_path_hashes_to ( & self ,
@@ -92,7 +92,7 @@ impl DefPathTable {
92
92
pub struct Definitions {
93
93
table : DefPathTable ,
94
94
node_to_def_index : NodeMap < DefIndex > ,
95
- def_index_to_node : Vec < ast:: NodeId > ,
95
+ def_index_to_node : IndexVec < DefIndex , ast:: NodeId > ,
96
96
pub ( super ) node_to_hir_id : IndexVec < ast:: NodeId , hir:: HirId > ,
97
97
/// If `ExpnId` is an ID of some macro expansion,
98
98
/// then `DefId` is the normal module (`mod`) in which the expanded macro was defined.
@@ -375,7 +375,7 @@ impl Definitions {
375
375
#[ inline]
376
376
pub fn as_local_node_id ( & self , def_id : DefId ) -> Option < ast:: NodeId > {
377
377
if def_id. krate == LOCAL_CRATE {
378
- let node_id = self . def_index_to_node [ def_id. index . index ( ) ] ;
378
+ let node_id = self . def_index_to_node [ def_id. index ] ;
379
379
if node_id != ast:: DUMMY_NODE_ID {
380
380
return Some ( node_id) ;
381
381
}
@@ -404,7 +404,7 @@ impl Definitions {
404
404
405
405
#[ inline]
406
406
pub fn def_index_to_hir_id ( & self , def_index : DefIndex ) -> hir:: HirId {
407
- let node_id = self . def_index_to_node [ def_index. index ( ) ] ;
407
+ let node_id = self . def_index_to_node [ def_index] ;
408
408
self . node_to_hir_id [ node_id]
409
409
}
410
410
0 commit comments