@@ -496,8 +496,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
496
496
}
497
497
}
498
498
499
- let res =
500
- self . expect_full_res_from_use ( id) . map ( |res| self . lower_res ( res) ) . collect ( ) ;
499
+ let res = self . lower_import_res ( id, path. span ) ;
501
500
let path = self . lower_use_path ( res, & path, ParamMode :: Explicit ) ;
502
501
hir:: ItemKind :: Use ( path, hir:: UseKind :: Single )
503
502
}
@@ -533,7 +532,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
533
532
// for that we return the `{}` import (called the
534
533
// `ListStem`).
535
534
536
- let prefix = Path { segments, span : prefix. span . to ( path. span ) , tokens : None } ;
535
+ let span = prefix. span . to ( path. span ) ;
536
+ let prefix = Path { segments, span, tokens : None } ;
537
537
538
538
// Add all the nested `PathListItem`s to the HIR.
539
539
for & ( ref use_tree, id) in trees {
@@ -567,9 +567,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
567
567
} ) ;
568
568
}
569
569
570
- let res =
571
- self . expect_full_res_from_use ( id) . map ( |res| self . lower_res ( res) ) . collect ( ) ;
572
- let path = self . lower_use_path ( res, & prefix, ParamMode :: Explicit ) ;
570
+ let path = if trees. is_empty ( ) && !prefix. segments . is_empty ( ) {
571
+ // For empty lists we need to lower the prefix so it is checked for things
572
+ // like stability later.
573
+ let res = self . lower_import_res ( id, span) ;
574
+ self . lower_use_path ( res, & prefix, ParamMode :: Explicit )
575
+ } else {
576
+ // For non-empty lists we can just drop all the data, the prefix is already
577
+ // present in HIR as a part of nested imports.
578
+ self . arena . alloc ( hir:: UsePath { res : smallvec ! [ ] , segments : & [ ] , span } )
579
+ } ;
573
580
hir:: ItemKind :: Use ( path, hir:: UseKind :: ListStem )
574
581
}
575
582
}
0 commit comments