@@ -3,7 +3,7 @@ use rustc_ast::ptr::P;
3
3
use rustc_ast:: visit:: AssocCtxt ;
4
4
use rustc_ast:: * ;
5
5
use rustc_errors:: ErrorGuaranteed ;
6
- use rustc_hir:: def:: { DefKind , Res } ;
6
+ use rustc_hir:: def:: { DefKind , PerNS , Res } ;
7
7
use rustc_hir:: def_id:: { CRATE_DEF_ID , LocalDefId } ;
8
8
use rustc_hir:: { self as hir, HirId , LifetimeSource , PredicateOrigin } ;
9
9
use rustc_index:: { IndexSlice , IndexVec } ;
@@ -527,7 +527,22 @@ impl<'hir> LoweringContext<'_, 'hir> {
527
527
}
528
528
UseTreeKind :: Glob => {
529
529
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
+ } ;
531
546
let path = Path { segments, span : path. span , tokens : None } ;
532
547
let path = self . lower_use_path ( res, & path, ParamMode :: Explicit ) ;
533
548
hir:: ItemKind :: Use ( path, hir:: UseKind :: Glob )
@@ -601,7 +616,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
601
616
} else {
602
617
// For non-empty lists we can just drop all the data, the prefix is already
603
618
// 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 } )
605
620
} ;
606
621
hir:: ItemKind :: Use ( path, hir:: UseKind :: ListStem )
607
622
}
0 commit comments