@@ -375,9 +375,13 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
375
375
use std:: collections:: vec_deque:: VecDeque ;
376
376
377
377
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.
381
385
let mut fallback_map: DefIdMap < DefId > = Default :: default ( ) ;
382
386
383
387
// Issue 46112: We want the map to prefer the shortest
@@ -412,6 +416,11 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
412
416
return ;
413
417
}
414
418
419
+ if ty:: util:: is_doc_hidden ( tcx, parent) {
420
+ fallback_map. insert ( def_id, parent) ;
421
+ return ;
422
+ }
423
+
415
424
match visible_parent_map. entry ( def_id) {
416
425
Entry :: Occupied ( mut entry) => {
417
426
// If `child` is defined in crate `cnum`, ensure
@@ -439,8 +448,9 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
439
448
}
440
449
}
441
450
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 `::*`.
444
454
for ( child, parent) in fallback_map {
445
455
visible_parent_map. entry ( child) . or_insert ( parent) ;
446
456
}
0 commit comments