@@ -50,14 +50,23 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<
5050 let mut inserted = FxHashSet :: default ( ) ;
5151 items. extend ( doc. foreigns . iter ( ) . map ( |( item, renamed) | {
5252 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 ) {
5454 inserted. insert ( ( item. type_ ( ) , name) ) ;
5555 }
5656 item
5757 } ) ) ;
58- items. extend ( doc. mods . iter ( ) . map ( |x| {
59- inserted. insert ( ( ItemType :: Module , x. name ) ) ;
60- clean_doc_module ( x, cx)
58+ items. extend ( doc. mods . iter ( ) . filter_map ( |x| {
59+ if !inserted. insert ( ( ItemType :: Module , x. name ) ) {
60+ return None ;
61+ }
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)
6170 } ) ) ;
6271
6372 // Split up imports from all other items.
@@ -72,7 +81,7 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<
7281 }
7382 let v = clean_maybe_renamed_item ( cx, item, * renamed) ;
7483 for item in & v {
75- if let Some ( name) = item. name {
84+ if let Some ( name) = item. name && !item . attrs . lists ( sym :: doc ) . has_word ( sym :: hidden ) {
7685 inserted. insert ( ( item. type_ ( ) , name) ) ;
7786 }
7887 }
0 commit comments