@@ -27,8 +27,8 @@ use syntax_pos::{Span, DUMMY_SP};
2727/// There is one `DefPathTable` for each crate.
2828#[ derive( Clone , Default , RustcDecodable , RustcEncodable ) ]
2929pub 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 > ,
3232}
3333
3434impl DefPathTable {
@@ -53,14 +53,14 @@ impl DefPathTable {
5353
5454 #[ inline( always) ]
5555 pub fn def_key ( & self , index : DefIndex ) -> DefKey {
56- self . index_to_key [ index. index ( ) ]
56+ self . index_to_key [ index]
5757 }
5858
5959 #[ inline( always) ]
6060 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
6464 }
6565
6666 pub fn add_def_path_hashes_to ( & self ,
@@ -92,7 +92,7 @@ impl DefPathTable {
9292pub struct Definitions {
9393 table : DefPathTable ,
9494 node_to_def_index : NodeMap < DefIndex > ,
95- def_index_to_node : Vec < ast:: NodeId > ,
95+ def_index_to_node : IndexVec < DefIndex , ast:: NodeId > ,
9696 pub ( super ) node_to_hir_id : IndexVec < ast:: NodeId , hir:: HirId > ,
9797 /// If `ExpnId` is an ID of some macro expansion,
9898 /// then `DefId` is the normal module (`mod`) in which the expanded macro was defined.
@@ -375,7 +375,7 @@ impl Definitions {
375375 #[ inline]
376376 pub fn as_local_node_id ( & self , def_id : DefId ) -> Option < ast:: NodeId > {
377377 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 ] ;
379379 if node_id != ast:: DUMMY_NODE_ID {
380380 return Some ( node_id) ;
381381 }
@@ -404,7 +404,7 @@ impl Definitions {
404404
405405 #[ inline]
406406 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] ;
408408 self . node_to_hir_id [ node_id]
409409 }
410410
0 commit comments