@@ -344,15 +344,38 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
344344 }
345345
346346 for ( _, myitem) in & not_stripped_items[ & type_] {
347+ let visibility_and_hidden = |item : & clean:: Item | match item. visibility ( tcx) {
348+ Some ( ty:: Visibility :: Restricted ( _) ) => {
349+ if item. is_doc_hidden ( ) {
350+ // Don't separate with a space when there are two of them
351+ "<span title=\" Restricted Visibility\" > 🔒</span><span title=\" Hidden item\" >👻</span> "
352+ } else {
353+ "<span title=\" Restricted Visibility\" > 🔒</span> "
354+ }
355+ }
356+ _ if item. is_doc_hidden ( ) => "<span title=\" Hidden item\" > 👻</span> " ,
357+ _ => "" ,
358+ } ;
359+
347360 match myitem. kind {
348361 clean:: ExternCrateItem { ref src } => {
349362 use crate :: html:: format:: print_anchor;
350363
364+ let visibility_and_hidden = visibility_and_hidden ( myitem) ;
365+ // Module listings use the hidden marker, so skip doc(hidden) here.
366+ super :: render_attributes_in_code_with_options (
367+ w,
368+ myitem,
369+ "" ,
370+ cx,
371+ false ,
372+ "<dt><code>" ,
373+ ) ?;
351374 match * src {
352375 Some ( src) => {
353376 write ! (
354377 w,
355- "<dt><code> {}extern crate {} as {};" ,
378+ "{}extern crate {} as {};" ,
356379 visibility_print_with_space( myitem, cx) ,
357380 print_anchor( myitem. item_id. expect_def_id( ) , src, cx) ,
358381 EscapeBodyTextWithWbr ( myitem. name. unwrap( ) . as_str( ) )
@@ -361,7 +384,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
361384 None => {
362385 write ! (
363386 w,
364- "<dt><code> {}extern crate {};" ,
387+ "{}extern crate {};" ,
365388 visibility_print_with_space( myitem, cx) ,
366389 print_anchor(
367390 myitem. item_id. expect_def_id( ) ,
@@ -371,7 +394,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
371394 ) ?;
372395 }
373396 }
374- write ! ( w, "</code></dt>" ) ?
397+ write ! ( w, "</code>{visibility_and_hidden} </dt>" ) ?
375398 }
376399 clean:: ImportItem ( ref import) => {
377400 let ( stab_tags, deprecation) = match import. source . did {
@@ -386,6 +409,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
386409 }
387410 None => ( String :: new ( ) , item. is_deprecated ( tcx) ) ,
388411 } ;
412+ let visibility_and_hidden = visibility_and_hidden ( myitem) ;
389413 let id = match import. kind {
390414 clean:: ImportKind :: Simple ( s) => {
391415 format ! ( " id=\" {}\" " , cx. derive_id( format!( "reexport.{s}" ) ) )
@@ -397,13 +421,13 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
397421 "<dt{id}{deprecation_attr}><code>" ,
398422 deprecation_attr = deprecation_class_attr( deprecation)
399423 ) ?;
400- render_attributes_in_code ( w, myitem, "" , cx) ?;
401424 write ! (
402425 w,
403- "{vis}{imp}</code>{stab_tags}\
426+ "{vis}{imp}</code>{visibility_and_hidden}{ stab_tags}\
404427 </dt>",
405428 vis = visibility_print_with_space( myitem, cx) ,
406429 imp = print_import( import, cx) ,
430+ visibility_and_hidden = visibility_and_hidden,
407431 ) ?;
408432 }
409433 _ => {
@@ -421,20 +445,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
421445 }
422446 _ => "" ,
423447 } ;
424- let visibility_and_hidden = match myitem. visibility ( tcx) {
425- Some ( ty:: Visibility :: Restricted ( _) ) => {
426- if myitem. is_doc_hidden ( ) {
427- // Don't separate with a space when there are two of them
428- "<span title=\" Restricted Visibility\" > 🔒</span><span title=\" Hidden item\" >👻</span> "
429- } else {
430- "<span title=\" Restricted Visibility\" > 🔒</span> "
431- }
432- }
433- _ if myitem. is_doc_hidden ( ) => {
434- "<span title=\" Hidden item\" > 👻</span> "
435- }
436- _ => "" ,
437- } ;
448+ let visibility_and_hidden = visibility_and_hidden ( myitem) ;
438449
439450 let docs = MarkdownSummaryLine ( & myitem. doc_value ( ) , & myitem. links ( cx) )
440451 . into_string ( ) ;
@@ -1868,7 +1879,6 @@ fn item_variants(
18681879fn item_macro ( cx : & Context < ' _ > , it : & clean:: Item , t : & clean:: Macro ) -> impl fmt:: Display {
18691880 fmt:: from_fn ( |w| {
18701881 wrap_item ( w, |w| {
1871- // FIXME: Also print `#[doc(hidden)]` for `macro_rules!` if it `is_doc_hidden`.
18721882 render_attributes_in_code ( w, it, "" , cx) ?;
18731883 if !t. macro_rules {
18741884 write ! ( w, "{}" , visibility_print_with_space( it, cx) ) ?;
0 commit comments