@@ -29,8 +29,7 @@ use rustc_target::spec::abi::Abi;
2929use  itertools:: Itertools ; 
3030
3131use  crate :: clean:: { 
32-  self ,  types:: ExternalLocation ,  utils:: find_nearest_parent_module,  ExternalCrate ,  ItemId , 
33-  PrimitiveType , 
32+  self ,  types:: ExternalLocation ,  utils:: find_nearest_parent_module,  ExternalCrate ,  PrimitiveType , 
3433} ; 
3534use  crate :: formats:: cache:: Cache ; 
3635use  crate :: formats:: item_type:: ItemType ; 
@@ -1506,20 +1505,18 @@ impl clean::FnDecl {
15061505} 
15071506
15081507pub ( crate )  fn  visibility_print_with_space < ' a ,  ' tcx :  ' a > ( 
1509-  visibility :  Option < ty:: Visibility < DefId > > , 
1510-  item_did :  ItemId , 
1508+  item :  & clean:: Item , 
15111509 cx :  & ' a  Context < ' tcx > , 
15121510)  -> impl  Display  + ' a  + Captures < ' tcx >  { 
15131511 use  std:: fmt:: Write  as  _; 
1514- 
1515-  let  to_print:  Cow < ' static ,  str >  = match  visibility { 
1512+  let  vis:  Cow < ' static ,  str >  = match  item. visibility ( cx. tcx ( ) )  { 
15161513 None  => "" . into ( ) , 
15171514 Some ( ty:: Visibility :: Public )  => "pub " . into ( ) , 
15181515 Some ( ty:: Visibility :: Restricted ( vis_did) )  => { 
15191516 // FIXME(camelid): This may not work correctly if `item_did` is a module. 
15201517 // However, rustdoc currently never displays a module's 
15211518 // visibility, so it shouldn't matter. 
1522-  let  parent_module = find_nearest_parent_module ( cx. tcx ( ) ,  item_did . expect_def_id ( ) ) ; 
1519+  let  parent_module = find_nearest_parent_module ( cx. tcx ( ) ,  item . item_id . expect_def_id ( ) ) ; 
15231520
15241521 if  vis_did. is_crate_root ( )  { 
15251522 "pub(crate) " . into ( ) 
@@ -1547,7 +1544,15 @@ pub(crate) fn visibility_print_with_space<'a, 'tcx: 'a>(
15471544 } 
15481545 } 
15491546 } ; 
1550-  display_fn ( move  |f| f. write_str ( & to_print) ) 
1547+ 
1548+  let  is_doc_hidden = item. is_doc_hidden ( ) ; 
1549+  display_fn ( move  |f| { 
1550+  if  is_doc_hidden { 
1551+  f. write_str ( "#[doc(hidden)] " ) ?; 
1552+  } 
1553+ 
1554+  f. write_str ( & vis) 
1555+  } ) 
15511556} 
15521557
15531558/// This function is the same as print_with_space, except that it renders no links. 
@@ -1557,8 +1562,9 @@ pub(crate) fn visibility_to_src_with_space<'a, 'tcx: 'a>(
15571562 visibility :  Option < ty:: Visibility < DefId > > , 
15581563 tcx :  TyCtxt < ' tcx > , 
15591564 item_did :  DefId , 
1565+  is_doc_hidden :  bool , 
15601566)  -> impl  Display  + ' a  + Captures < ' tcx >  { 
1561-  let  to_print :  Cow < ' static ,  str >  = match  visibility { 
1567+  let  vis :  Cow < ' static ,  str >  = match  visibility { 
15621568 None  => "" . into ( ) , 
15631569 Some ( ty:: Visibility :: Public )  => "pub " . into ( ) , 
15641570 Some ( ty:: Visibility :: Restricted ( vis_did) )  => { 
@@ -1582,7 +1588,12 @@ pub(crate) fn visibility_to_src_with_space<'a, 'tcx: 'a>(
15821588 } 
15831589 } 
15841590 } ; 
1585-  display_fn ( move  |f| f. write_str ( & to_print) ) 
1591+  display_fn ( move  |f| { 
1592+  if  is_doc_hidden { 
1593+  f. write_str ( "#[doc(hidden)] " ) ?; 
1594+  } 
1595+  f. write_str ( & vis) 
1596+  } ) 
15861597} 
15871598
15881599pub ( crate )  trait  PrintWithSpace  { 
0 commit comments