@@ -29,8 +29,7 @@ use rustc_target::spec::abi::Abi;
29
29
use itertools:: Itertools ;
30
30
31
31
use 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 ,
34
33
} ;
35
34
use crate :: formats:: cache:: Cache ;
36
35
use crate :: formats:: item_type:: ItemType ;
@@ -1506,20 +1505,18 @@ impl clean::FnDecl {
1506
1505
}
1507
1506
1508
1507
pub ( crate ) fn visibility_print_with_space < ' a , ' tcx : ' a > (
1509
- visibility : Option < ty:: Visibility < DefId > > ,
1510
- item_did : ItemId ,
1508
+ item : & clean:: Item ,
1511
1509
cx : & ' a Context < ' tcx > ,
1512
1510
) -> impl Display + ' a + Captures < ' tcx > {
1513
1511
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 ( ) ) {
1516
1513
None => "" . into ( ) ,
1517
1514
Some ( ty:: Visibility :: Public ) => "pub " . into ( ) ,
1518
1515
Some ( ty:: Visibility :: Restricted ( vis_did) ) => {
1519
1516
// FIXME(camelid): This may not work correctly if `item_did` is a module.
1520
1517
// However, rustdoc currently never displays a module's
1521
1518
// 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 ( ) ) ;
1523
1520
1524
1521
if vis_did. is_crate_root ( ) {
1525
1522
"pub(crate) " . into ( )
@@ -1547,7 +1544,15 @@ pub(crate) fn visibility_print_with_space<'a, 'tcx: 'a>(
1547
1544
}
1548
1545
}
1549
1546
} ;
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
+ } )
1551
1556
}
1552
1557
1553
1558
/// 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>(
1557
1562
visibility : Option < ty:: Visibility < DefId > > ,
1558
1563
tcx : TyCtxt < ' tcx > ,
1559
1564
item_did : DefId ,
1565
+ is_doc_hidden : bool ,
1560
1566
) -> impl Display + ' a + Captures < ' tcx > {
1561
- let to_print : Cow < ' static , str > = match visibility {
1567
+ let vis : Cow < ' static , str > = match visibility {
1562
1568
None => "" . into ( ) ,
1563
1569
Some ( ty:: Visibility :: Public ) => "pub " . into ( ) ,
1564
1570
Some ( ty:: Visibility :: Restricted ( vis_did) ) => {
@@ -1582,7 +1588,12 @@ pub(crate) fn visibility_to_src_with_space<'a, 'tcx: 'a>(
1582
1588
}
1583
1589
}
1584
1590
} ;
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
+ } )
1586
1597
}
1587
1598
1588
1599
pub ( crate ) trait PrintWithSpace {
0 commit comments