@@ -361,9 +361,40 @@ impl<'a> LoweringContext<'a> {
361361 lctx : & ' lcx mut LoweringContext < ' interner > ,
362362 }
363363
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+
364395 impl < ' lcx , ' interner > Visitor < ' lcx > for MiscCollector < ' lcx , ' interner > {
365396 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 ;
367398
368399 match item. node {
369400 ItemKind :: Struct ( _, ref generics)
@@ -383,6 +414,9 @@ impl<'a> LoweringContext<'a> {
383414 . count ( ) ;
384415 self . lctx . type_def_lifetime_params . insert ( def_id, count) ;
385416 }
417+ ItemKind :: Use ( ref use_tree) => {
418+ self . allocate_use_tree_hir_id_counters ( use_tree, hir_id. owner ) ;
419+ }
386420 _ => { }
387421 }
388422 visit:: walk_item ( self , item) ;
@@ -517,6 +551,8 @@ impl<'a> LoweringContext<'a> {
517551
518552 fn insert_item ( & mut self , item : hir:: Item ) {
519553 let id = item. hir_id ;
554+ // FIXME: Use debug_asset-rt
555+ assert_eq ! ( id. local_id, hir:: ItemLocalId :: from_u32( 0 ) ) ;
520556 self . items . insert ( id, item) ;
521557 self . modules . get_mut ( & self . current_module ) . unwrap ( ) . items . insert ( id) ;
522558 }
@@ -3065,7 +3101,6 @@ impl<'a> LoweringContext<'a> {
30653101 }
30663102 }
30673103
3068- let parent_def_index = self . current_hir_id_owner . last ( ) . unwrap ( ) . 0 ;
30693104 let mut defs = self . expect_full_def_from_use ( id) ;
30703105 // We want to return *something* from this function, so hold onto the first item
30713106 // for later.
@@ -3084,14 +3119,6 @@ impl<'a> LoweringContext<'a> {
30843119 seg. id = self . sess . next_node_id ( ) ;
30853120 }
30863121 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) ;
30953122
30963123 self . with_hir_id_owner ( new_node_id, |this| {
30973124 let new_id = this. lower_node_id ( new_node_id) ;
@@ -3173,8 +3200,6 @@ impl<'a> LoweringContext<'a> {
31733200
31743201 // Add all the nested `PathListItem`s to the HIR.
31753202 for & ( ref use_tree, id) in trees {
3176- self . allocate_hir_id_counter ( id, & use_tree) ;
3177-
31783203 let LoweredNodeId {
31793204 node_id : new_id,
31803205 hir_id : new_hir_id,
@@ -3469,9 +3494,11 @@ impl<'a> LoweringContext<'a> {
34693494 _ => smallvec ! [ i. id] ,
34703495 } ;
34713496
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 ( )
34753502 }
34763503
34773504 fn lower_item_id_use_tree ( & mut self ,
0 commit comments