@@ -50,7 +50,7 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<
50
50
let mut inserted = FxHashSet :: default ( ) ;
51
51
items. extend ( doc. foreigns . iter ( ) . map ( |( item, renamed) | {
52
52
let item = clean_maybe_renamed_foreign_item ( cx, item, * renamed) ;
53
- if let Some ( name) = item. name {
53
+ if let Some ( name) = item. name && !item . attrs . lists ( sym :: doc ) . has_word ( sym :: hidden ) {
54
54
inserted. insert ( ( item. type_ ( ) , name) ) ;
55
55
}
56
56
item
@@ -59,7 +59,14 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<
59
59
if !inserted. insert ( ( ItemType :: Module , x. name ) ) {
60
60
return None ;
61
61
}
62
- Some ( clean_doc_module ( x, cx) )
62
+ let item = clean_doc_module ( x, cx) ;
63
+ if item. attrs . lists ( sym:: doc) . has_word ( sym:: hidden) {
64
+ // Hidden modules are stripped at a later stage.
65
+ // If a hidden module has the same name as a visible one, we want
66
+ // to keep both of them around.
67
+ inserted. remove ( & ( ItemType :: Module , x. name ) ) ;
68
+ }
69
+ Some ( item)
63
70
} ) ) ;
64
71
65
72
// Split up imports from all other items.
@@ -74,7 +81,7 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<
74
81
}
75
82
let v = clean_maybe_renamed_item ( cx, item, * renamed) ;
76
83
for item in & v {
77
- if let Some ( name) = item. name {
84
+ if let Some ( name) = item. name && !item . attrs . lists ( sym :: doc ) . has_word ( sym :: hidden ) {
78
85
inserted. insert ( ( item. type_ ( ) , name) ) ;
79
86
}
80
87
}
0 commit comments