@@ -475,7 +475,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
475475 }
476476 }
477477
478- let mut resolutions = self . expect_full_res_from_use ( id) ;
478+ let mut resolutions = self . expect_full_res_from_use ( id) . fuse ( ) ;
479479 // We want to return *something* from this function, so hold onto the first item
480480 // for later.
481481 let ret_res = self . lower_res ( resolutions. next ( ) . unwrap_or ( Res :: Err ) ) ;
@@ -485,7 +485,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
485485 // won't be dealing with macros in the rest of the compiler.
486486 // Essentially a single `use` which imports two names is desugared into
487487 // two imports.
488- for ( res, & new_node_id) in iter:: zip ( resolutions, & [ id1, id2] ) {
488+ for new_node_id in [ id1, id2] {
489+ // Associate an HirId to both ids even if there is no resolution.
490+ let new_id = self . allocate_hir_id_counter ( new_node_id) ;
491+
492+ let res = if let Some ( res) = resolutions. next ( ) { res } else { continue } ;
489493 let ident = * ident;
490494 let mut path = path. clone ( ) ;
491495 for seg in & mut path. segments {
@@ -494,17 +498,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
494498 let span = path. span ;
495499
496500 self . with_hir_id_owner ( new_node_id, |this| {
497- let new_id = this. lower_node_id ( new_node_id) ;
498501 let res = this. lower_res ( res) ;
499502 let path = this. lower_path_extra ( res, & path, ParamMode :: Explicit , None ) ;
500503 let kind = hir:: ItemKind :: Use ( path, hir:: UseKind :: Single ) ;
501504 let vis = this. rebuild_vis ( & vis) ;
502505 if let Some ( attrs) = attrs {
503- this. attrs . insert ( new_id, attrs) ;
506+ this. attrs . insert ( hir :: HirId :: make_owner ( new_id) , attrs) ;
504507 }
505508
506509 this. insert_item ( hir:: Item {
507- def_id : new_id. expect_owner ( ) ,
510+ def_id : new_id,
508511 ident : this. lower_ident ( ident) ,
509512 kind,
510513 vis,
@@ -553,7 +556,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
553556
554557 // Add all the nested `PathListItem`s to the HIR.
555558 for & ( ref use_tree, id) in trees {
556- let new_hir_id = self . lower_node_id ( id) ;
559+ let new_hir_id = self . allocate_hir_id_counter ( id) ;
557560
558561 let mut prefix = prefix. clone ( ) ;
559562
@@ -574,11 +577,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
574577 let kind =
575578 this. lower_use_tree ( use_tree, & prefix, id, & mut vis, & mut ident, attrs) ;
576579 if let Some ( attrs) = attrs {
577- this. attrs . insert ( new_hir_id, attrs) ;
580+ this. attrs . insert ( hir :: HirId :: make_owner ( new_hir_id) , attrs) ;
578581 }
579582
580583 this. insert_item ( hir:: Item {
581- def_id : new_hir_id. expect_owner ( ) ,
584+ def_id : new_hir_id,
582585 ident : this. lower_ident ( ident) ,
583586 kind,
584587 vis,
0 commit comments