@@ -3,7 +3,7 @@ use rustc_ast::ptr::P;
33use rustc_ast:: visit:: AssocCtxt ;
44use rustc_ast:: * ;
55use rustc_errors:: ErrorGuaranteed ;
6- use rustc_hir:: def:: { DefKind , Res } ;
6+ use rustc_hir:: def:: { DefKind , PerNS , Res } ;
77use rustc_hir:: def_id:: { CRATE_DEF_ID , LocalDefId } ;
88use rustc_hir:: { self as hir, HirId , LifetimeSource , PredicateOrigin } ;
99use rustc_index:: { IndexSlice , IndexVec } ;
@@ -527,7 +527,22 @@ impl<'hir> LoweringContext<'_, 'hir> {
527527 }
528528 UseTreeKind :: Glob => {
529529 let res = self . expect_full_res ( id) ;
530- let res = smallvec ! [ self . lower_res( res) ] ;
530+ let res = self . lower_res ( res) ;
531+ // Put the result in the appropriate namespace.
532+ let res = match res {
533+ Res :: Def ( DefKind :: Mod | DefKind :: Trait , _) => {
534+ PerNS { type_ns : Some ( res) , value_ns : None , macro_ns : None }
535+ }
536+ Res :: Def ( DefKind :: Enum , _) => {
537+ PerNS { type_ns : None , value_ns : Some ( res) , macro_ns : None }
538+ }
539+ Res :: Err => {
540+ // Propagate the error to all namespaces, just to be sure.
541+ let err = Some ( Res :: Err ) ;
542+ PerNS { type_ns : err, value_ns : err, macro_ns : err }
543+ }
544+ _ => panic ! ( "bad glob res {:?} at {:?}" , res, path. span) ,
545+ } ;
531546 let path = Path { segments, span : path. span , tokens : None } ;
532547 let path = self . lower_use_path ( res, & path, ParamMode :: Explicit ) ;
533548 hir:: ItemKind :: Use ( path, hir:: UseKind :: Glob )
@@ -601,7 +616,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
601616 } else {
602617 // For non-empty lists we can just drop all the data, the prefix is already
603618 // present in HIR as a part of nested imports.
604- self . arena . alloc ( hir:: UsePath { res : smallvec ! [ ] , segments : & [ ] , span } )
619+ self . arena . alloc ( hir:: UsePath { res : PerNS :: default ( ) , segments : & [ ] , span } )
605620 } ;
606621 hir:: ItemKind :: Use ( path, hir:: UseKind :: ListStem )
607622 }
0 commit comments