@@ -50,7 +50,7 @@ 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
@@ -59,7 +59,14 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<
5959 if !inserted. insert ( ( ItemType :: Module , x. name ) ) {
6060 return None ;
6161 }
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)
6370 } ) ) ;
6471
6572 // Split up imports from all other items.
@@ -74,7 +81,7 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<
7481 }
7582 let v = clean_maybe_renamed_item ( cx, item, * renamed) ;
7683 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 ) {
7885 inserted. insert ( ( item. type_ ( ) , name) ) ;
7986 }
8087 }
0 commit comments