@@ -361,9 +361,40 @@ impl<'a> LoweringContext<'a> {
361
361
lctx : & ' lcx mut LoweringContext < ' interner > ,
362
362
}
363
363
364
+ impl MiscCollector < ' _ , ' _ > {
365
+ fn allocate_use_tree_hir_id_counters (
366
+ & mut self ,
367
+ tree : & UseTree ,
368
+ owner : DefIndex ,
369
+ ) {
370
+ match tree. kind {
371
+ UseTreeKind :: Simple ( _, id1, id2) => {
372
+ for & id in & [ id1, id2] {
373
+ self . lctx . resolver . definitions ( ) . create_def_with_parent (
374
+ owner,
375
+ id,
376
+ DefPathData :: Misc ,
377
+ DefIndexAddressSpace :: High ,
378
+ Mark :: root ( ) ,
379
+ tree. prefix . span ,
380
+ ) ;
381
+ self . lctx . allocate_hir_id_counter ( id, & tree) ;
382
+ }
383
+ }
384
+ UseTreeKind :: Glob => ( ) ,
385
+ UseTreeKind :: Nested ( ref trees) => {
386
+ for & ( ref use_tree, id) in trees {
387
+ let hir_id = self . lctx . allocate_hir_id_counter ( id, & use_tree) . hir_id ;
388
+ self . allocate_use_tree_hir_id_counters ( use_tree, hir_id. owner ) ;
389
+ }
390
+ }
391
+ }
392
+ }
393
+ }
394
+
364
395
impl < ' lcx , ' interner > Visitor < ' lcx > for MiscCollector < ' lcx , ' interner > {
365
396
fn visit_item ( & mut self , item : & ' lcx Item ) {
366
- self . lctx . allocate_hir_id_counter ( item. id , item) ;
397
+ let hir_id = self . lctx . allocate_hir_id_counter ( item. id , item) . hir_id ;
367
398
368
399
match item. node {
369
400
ItemKind :: Struct ( _, ref generics)
@@ -383,6 +414,9 @@ impl<'a> LoweringContext<'a> {
383
414
. count ( ) ;
384
415
self . lctx . type_def_lifetime_params . insert ( def_id, count) ;
385
416
}
417
+ ItemKind :: Use ( ref use_tree) => {
418
+ self . allocate_use_tree_hir_id_counters ( use_tree, hir_id. owner ) ;
419
+ }
386
420
_ => { }
387
421
}
388
422
visit:: walk_item ( self , item) ;
@@ -517,6 +551,8 @@ impl<'a> LoweringContext<'a> {
517
551
518
552
fn insert_item ( & mut self , item : hir:: Item ) {
519
553
let id = item. hir_id ;
554
+ // FIXME: Use debug_asset-rt
555
+ assert_eq ! ( id. local_id, hir:: ItemLocalId :: from_u32( 0 ) ) ;
520
556
self . items . insert ( id, item) ;
521
557
self . modules . get_mut ( & self . current_module ) . unwrap ( ) . items . insert ( id) ;
522
558
}
@@ -3065,7 +3101,6 @@ impl<'a> LoweringContext<'a> {
3065
3101
}
3066
3102
}
3067
3103
3068
- let parent_def_index = self . current_hir_id_owner . last ( ) . unwrap ( ) . 0 ;
3069
3104
let mut defs = self . expect_full_def_from_use ( id) ;
3070
3105
// We want to return *something* from this function, so hold onto the first item
3071
3106
// for later.
@@ -3084,14 +3119,6 @@ impl<'a> LoweringContext<'a> {
3084
3119
seg. id = self . sess . next_node_id ( ) ;
3085
3120
}
3086
3121
let span = path. span ;
3087
- self . resolver . definitions ( ) . create_def_with_parent (
3088
- parent_def_index,
3089
- new_node_id,
3090
- DefPathData :: Misc ,
3091
- DefIndexAddressSpace :: High ,
3092
- Mark :: root ( ) ,
3093
- span) ;
3094
- self . allocate_hir_id_counter ( new_node_id, & path) ;
3095
3122
3096
3123
self . with_hir_id_owner ( new_node_id, |this| {
3097
3124
let new_id = this. lower_node_id ( new_node_id) ;
@@ -3173,8 +3200,6 @@ impl<'a> LoweringContext<'a> {
3173
3200
3174
3201
// Add all the nested `PathListItem`s to the HIR.
3175
3202
for & ( ref use_tree, id) in trees {
3176
- self . allocate_hir_id_counter ( id, & use_tree) ;
3177
-
3178
3203
let LoweredNodeId {
3179
3204
node_id : new_id,
3180
3205
hir_id : new_hir_id,
@@ -3469,9 +3494,11 @@ impl<'a> LoweringContext<'a> {
3469
3494
_ => smallvec ! [ i. id] ,
3470
3495
} ;
3471
3496
3472
- node_ids. into_iter ( )
3473
- . map ( |node_id| hir:: ItemId { id : self . lower_node_id ( node_id) . hir_id } )
3474
- . collect ( )
3497
+ node_ids. into_iter ( ) . map ( |node_id| hir:: ItemId {
3498
+ id : self . lower_node_id_generic ( node_id, |_| {
3499
+ panic ! ( "expected node_id to be lowered already {:#?}" , i)
3500
+ } ) . hir_id
3501
+ } ) . collect ( )
3475
3502
}
3476
3503
3477
3504
fn lower_item_id_use_tree ( & mut self ,
0 commit comments