@@ -475,7 +475,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
475
475
}
476
476
}
477
477
478
- let mut resolutions = self . expect_full_res_from_use ( id) ;
478
+ let mut resolutions = self . expect_full_res_from_use ( id) . fuse ( ) ;
479
479
// We want to return *something* from this function, so hold onto the first item
480
480
// for later.
481
481
let ret_res = self . lower_res ( resolutions. next ( ) . unwrap_or ( Res :: Err ) ) ;
@@ -485,7 +485,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
485
485
// won't be dealing with macros in the rest of the compiler.
486
486
// Essentially a single `use` which imports two names is desugared into
487
487
// 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 } ;
489
493
let ident = * ident;
490
494
let mut path = path. clone ( ) ;
491
495
for seg in & mut path. segments {
@@ -494,17 +498,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
494
498
let span = path. span ;
495
499
496
500
self . with_hir_id_owner ( new_node_id, |this| {
497
- let new_id = this. lower_node_id ( new_node_id) ;
498
501
let res = this. lower_res ( res) ;
499
502
let path = this. lower_path_extra ( res, & path, ParamMode :: Explicit , None ) ;
500
503
let kind = hir:: ItemKind :: Use ( path, hir:: UseKind :: Single ) ;
501
504
let vis = this. rebuild_vis ( & vis) ;
502
505
if let Some ( attrs) = attrs {
503
- this. attrs . insert ( new_id, attrs) ;
506
+ this. attrs . insert ( hir :: HirId :: make_owner ( new_id) , attrs) ;
504
507
}
505
508
506
509
this. insert_item ( hir:: Item {
507
- def_id : new_id. expect_owner ( ) ,
510
+ def_id : new_id,
508
511
ident : this. lower_ident ( ident) ,
509
512
kind,
510
513
vis,
@@ -553,7 +556,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
553
556
554
557
// Add all the nested `PathListItem`s to the HIR.
555
558
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) ;
557
560
558
561
let mut prefix = prefix. clone ( ) ;
559
562
@@ -574,11 +577,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
574
577
let kind =
575
578
this. lower_use_tree ( use_tree, & prefix, id, & mut vis, & mut ident, attrs) ;
576
579
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) ;
578
581
}
579
582
580
583
this. insert_item ( hir:: Item {
581
- def_id : new_hir_id. expect_owner ( ) ,
584
+ def_id : new_hir_id,
582
585
ident : this. lower_ident ( ident) ,
583
586
kind,
584
587
vis,
0 commit comments