@@ -375,9 +375,13 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
375375 use std:: collections:: vec_deque:: VecDeque ;
376376
377377 let mut visible_parent_map: DefIdMap < DefId > = Default :: default ( ) ;
378- // This is a secondary visible_parent_map, storing the DefId of parents that re-export
379- // the child as `_`. Since we prefer parents that don't do this, merge this map at the
380- // end, only if we're missing any keys from the former.
378+ // This is a secondary visible_parent_map, storing the DefId of
379+ // parents that re-export the child as `_` or module parents
380+ // which are `#[doc(hidden)]`. Since we prefer paths that don't
381+ // do this, merge this map at the end, only if we're missing
382+ // keys from the former.
383+ // This is a rudimentary check that does not catch all cases,
384+ // just the easiest.
381385 let mut fallback_map: DefIdMap < DefId > = Default :: default ( ) ;
382386
383387 // Issue 46112: We want the map to prefer the shortest
@@ -412,6 +416,11 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
412416 return ;
413417 }
414418
419+ if ty:: util:: is_doc_hidden ( tcx, parent) {
420+ fallback_map. insert ( def_id, parent) ;
421+ return ;
422+ }
423+
415424 match visible_parent_map. entry ( def_id) {
416425 Entry :: Occupied ( mut entry) => {
417426 // If `child` is defined in crate `cnum`, ensure
@@ -439,8 +448,9 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
439448 }
440449 }
441450
442- // Fill in any missing entries with the (less preferable) path ending in `::_`.
443- // We still use this path in a diagnostic that suggests importing `::*`.
451+ // Fill in any missing entries with the less preferable path.
452+ // If this path re-exports the child as `_`, we still use this
453+ // path in a diagnostic that suggests importing `::*`.
444454 for ( child, parent) in fallback_map {
445455 visible_parent_map. entry ( child) . or_insert ( parent) ;
446456 }
0 commit comments