@@ -10,7 +10,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
10
10
use rustc_data_structures:: svh:: Svh ;
11
11
use rustc_hir as hir;
12
12
use rustc_hir:: def_id:: CRATE_DEF_INDEX ;
13
- use rustc_hir:: def_id:: { DefIndex , LOCAL_CRATE } ;
13
+ use rustc_hir:: def_id:: { LocalDefId , LOCAL_CRATE } ;
14
14
use rustc_hir:: intravisit:: { self , NestedVisitorMap , Visitor } ;
15
15
use rustc_hir:: * ;
16
16
use rustc_index:: vec:: { Idx , IndexVec } ;
@@ -30,12 +30,12 @@ pub(super) struct NodeCollector<'a, 'hir> {
30
30
/// Source map
31
31
source_map : & ' a SourceMap ,
32
32
33
- map : IndexVec < DefIndex , HirOwnerData < ' hir > > ,
33
+ map : IndexVec < LocalDefId , HirOwnerData < ' hir > > ,
34
34
35
35
/// The parent of this node
36
36
parent_node : hir:: HirId ,
37
37
38
- current_dep_node_owner : DefIndex ,
38
+ current_dep_node_owner : LocalDefId ,
39
39
40
40
definitions : & ' a definitions:: Definitions ,
41
41
@@ -98,7 +98,8 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
98
98
definitions : & ' a definitions:: Definitions ,
99
99
mut hcx : StableHashingContext < ' a > ,
100
100
) -> NodeCollector < ' a , ' hir > {
101
- let root_mod_def_path_hash = definitions. def_path_hash ( CRATE_DEF_INDEX ) ;
101
+ let root_mod_def_path_hash =
102
+ definitions. def_path_hash ( LocalDefId { local_def_index : CRATE_DEF_INDEX } ) ;
102
103
103
104
let mut hir_body_nodes = Vec :: new ( ) ;
104
105
@@ -126,7 +127,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
126
127
krate,
127
128
source_map : sess. source_map ( ) ,
128
129
parent_node : hir:: CRATE_HIR_ID ,
129
- current_dep_node_owner : CRATE_DEF_INDEX ,
130
+ current_dep_node_owner : LocalDefId { local_def_index : CRATE_DEF_INDEX } ,
130
131
definitions,
131
132
hcx,
132
133
hir_body_nodes,
@@ -148,7 +149,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
148
149
crate_disambiguator : CrateDisambiguator ,
149
150
cstore : & dyn CrateStore ,
150
151
commandline_args_hash : u64 ,
151
- ) -> ( IndexVec < DefIndex , HirOwnerData < ' hir > > , Svh ) {
152
+ ) -> ( IndexVec < LocalDefId , HirOwnerData < ' hir > > , Svh ) {
152
153
// Insert bodies into the map
153
154
for ( id, body) in self . krate . bodies . iter ( ) {
154
155
let bodies = & mut self . map [ id. hir_id . owner ] . with_bodies . as_mut ( ) . unwrap ( ) . bodies ;
@@ -244,8 +245,8 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
244
245
assert_eq ! ( self . definitions. node_to_hir_id( node_id) , hir_id) ;
245
246
246
247
if hir_id. owner != self . current_dep_node_owner {
247
- let node_str = match self . definitions . opt_def_index ( node_id) {
248
- Some ( def_index ) => self . definitions . def_path ( def_index ) . to_string_no_crate ( ) ,
248
+ let node_str = match self . definitions . opt_local_def_id ( node_id) {
249
+ Some ( def_id ) => self . definitions . def_path ( def_id ) . to_string_no_crate ( ) ,
249
250
None => format ! ( "{:?}" , node) ,
250
251
} ;
251
252
@@ -285,7 +286,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
285
286
F : FnOnce ( & mut Self , Fingerprint ) ,
286
287
> (
287
288
& mut self ,
288
- dep_node_owner : DefIndex ,
289
+ dep_node_owner : LocalDefId ,
289
290
item_like : & T ,
290
291
f : F ,
291
292
) {
@@ -341,7 +342,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
341
342
debug ! ( "visit_item: {:?}" , i) ;
342
343
debug_assert_eq ! (
343
344
i. hir_id. owner,
344
- self . definitions. opt_def_index ( self . definitions. hir_to_node_id( i. hir_id) ) . unwrap( )
345
+ self . definitions. opt_local_def_id ( self . definitions. hir_to_node_id( i. hir_id) ) . unwrap( )
345
346
) ;
346
347
self . with_dep_node_owner ( i. hir_id . owner , i, |this, hash| {
347
348
this. insert_with_hash ( i. span , i. hir_id , Node :: Item ( i) , hash) ;
@@ -373,7 +374,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
373
374
fn visit_trait_item ( & mut self , ti : & ' hir TraitItem < ' hir > ) {
374
375
debug_assert_eq ! (
375
376
ti. hir_id. owner,
376
- self . definitions. opt_def_index ( self . definitions. hir_to_node_id( ti. hir_id) ) . unwrap( )
377
+ self . definitions. opt_local_def_id ( self . definitions. hir_to_node_id( ti. hir_id) ) . unwrap( )
377
378
) ;
378
379
self . with_dep_node_owner ( ti. hir_id . owner , ti, |this, hash| {
379
380
this. insert_with_hash ( ti. span , ti. hir_id , Node :: TraitItem ( ti) , hash) ;
@@ -387,7 +388,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
387
388
fn visit_impl_item ( & mut self , ii : & ' hir ImplItem < ' hir > ) {
388
389
debug_assert_eq ! (
389
390
ii. hir_id. owner,
390
- self . definitions. opt_def_index ( self . definitions. hir_to_node_id( ii. hir_id) ) . unwrap( )
391
+ self . definitions. opt_local_def_id ( self . definitions. hir_to_node_id( ii. hir_id) ) . unwrap( )
391
392
) ;
392
393
self . with_dep_node_owner ( ii. hir_id . owner , ii, |this, hash| {
393
394
this. insert_with_hash ( ii. span , ii. hir_id , Node :: ImplItem ( ii) , hash) ;
@@ -506,10 +507,7 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
506
507
}
507
508
508
509
fn visit_macro_def ( & mut self , macro_def : & ' hir MacroDef < ' hir > ) {
509
- let node_id = self . definitions . hir_to_node_id ( macro_def. hir_id ) ;
510
- let def_index = self . definitions . opt_def_index ( node_id) . unwrap ( ) ;
511
-
512
- self . with_dep_node_owner ( def_index, macro_def, |this, hash| {
510
+ self . with_dep_node_owner ( macro_def. hir_id . owner , macro_def, |this, hash| {
513
511
this. insert_with_hash (
514
512
macro_def. span ,
515
513
macro_def. hir_id ,
0 commit comments