@@ -496,8 +496,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
496496 }
497497 }
498498
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 ) ;
501500 let path = self . lower_use_path ( res, & path, ParamMode :: Explicit ) ;
502501 hir:: ItemKind :: Use ( path, hir:: UseKind :: Single )
503502 }
@@ -533,7 +532,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
533532 // for that we return the `{}` import (called the
534533 // `ListStem`).
535534
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 } ;
537537
538538 // Add all the nested `PathListItem`s to the HIR.
539539 for & ( ref use_tree, id) in trees {
@@ -567,9 +567,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
567567 } ) ;
568568 }
569569
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+ } ;
573580 hir:: ItemKind :: Use ( path, hir:: UseKind :: ListStem )
574581 }
575582 }
0 commit comments