@@ -9,7 +9,7 @@ use rustc_ast as ast;
99use rustc_data_structures:: fx:: FxHashSet ;
1010use rustc_hir as hir;
1111use rustc_hir:: def:: { DefKind , Res } ;
12- use rustc_hir:: def_id:: DefId ;
12+ use rustc_hir:: def_id:: { DefId , LocalDefId } ;
1313use rustc_hir:: Mutability ;
1414use rustc_metadata:: creader:: { CStore , LoadedMacro } ;
1515use rustc_middle:: ty:: { self , TyCtxt } ;
@@ -162,6 +162,7 @@ pub(crate) fn try_inline(
162162pub ( crate ) fn try_inline_glob (
163163 cx : & mut DocContext < ' _ > ,
164164 res : Res ,
165+ current_mod : LocalDefId ,
165166 visited : & mut FxHashSet < DefId > ,
166167 inlined_names : & mut FxHashSet < ( ItemType , Symbol ) > ,
167168) -> Option < Vec < clean:: Item > > {
@@ -172,7 +173,16 @@ pub(crate) fn try_inline_glob(
172173
173174 match res {
174175 Res :: Def ( DefKind :: Mod , did) => {
175- let mut items = build_module_items ( cx, did, visited, inlined_names) ;
176+ // Use the set of module reexports to filter away names that are not actually
177+ // reexported by the glob, e.g. because they are shadowed by something else.
178+ let reexports = cx
179+ . tcx
180+ . module_reexports ( current_mod)
181+ . unwrap_or_default ( )
182+ . iter ( )
183+ . filter_map ( |child| child. res . opt_def_id ( ) )
184+ . collect ( ) ;
185+ let mut items = build_module_items ( cx, did, visited, inlined_names, Some ( & reexports) ) ;
176186 items. drain_filter ( |item| {
177187 if let Some ( name) = item. name {
178188 // If an item with the same type and name already exists,
@@ -563,7 +573,7 @@ fn build_module(
563573 did : DefId ,
564574 visited : & mut FxHashSet < DefId > ,
565575) -> clean:: Module {
566- let items = build_module_items ( cx, did, visited, & mut FxHashSet :: default ( ) ) ;
576+ let items = build_module_items ( cx, did, visited, & mut FxHashSet :: default ( ) , None ) ;
567577
568578 let span = clean:: Span :: new ( cx. tcx . def_span ( did) ) ;
569579 clean:: Module { items, span }
@@ -574,6 +584,7 @@ fn build_module_items(
574584 did : DefId ,
575585 visited : & mut FxHashSet < DefId > ,
576586 inlined_names : & mut FxHashSet < ( ItemType , Symbol ) > ,
587+ allowed_def_ids : Option < & FxHashSet < DefId > > ,
577588) -> Vec < clean:: Item > {
578589 let mut items = Vec :: new ( ) ;
579590
@@ -583,6 +594,11 @@ fn build_module_items(
583594 for & item in cx. tcx . module_children ( did) . iter ( ) {
584595 if item. vis . is_public ( ) {
585596 let res = item. res . expect_non_local ( ) ;
597+ if let Some ( def_id) = res. opt_def_id ( )
598+ && let Some ( allowed_def_ids) = allowed_def_ids
599+ && !allowed_def_ids. contains ( & def_id) {
600+ continue ;
601+ }
586602 if let Some ( def_id) = res. mod_def_id ( ) {
587603 // If we're inlining a glob import, it's possible to have
588604 // two distinct modules with the same name. We don't want to
0 commit comments