Skip to content

Commit 298cd36

Browse files
Add test for private items
1 parent 9fb6548 commit 298cd36

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,9 @@ fn first_non_private(
15531553
continue;
15541554
}
15551555
if !cx.tcx.is_doc_hidden(use_def_id) &&
1556+
// We never check for "cx.render_options.document_private"
1557+
// because if a re-export is not fully public, it's never
1558+
// documented.
15561559
cx.tcx.local_visibility(local_use_def_id).is_public() {
15571560
break 'reexps;
15581561
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// compile-flags: --document-private-items
2+
3+
#![crate_name = "foo"]
4+
5+
use crate::bar::Bar as Alias;
6+
pub(crate) use crate::bar::Bar as CrateAlias;
7+
8+
mod bar {
9+
pub struct Bar;
10+
pub use self::Bar as Inner;
11+
}
12+
13+
// It's a fully private re-export so it should not be displayed.
14+
// @has 'foo/fn.bar.html'
15+
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Bar'
16+
pub fn bar() -> Alias {
17+
Alias
18+
}
19+
20+
// It's public re-export inside a private module so it should be visible.
21+
// @has 'foo/fn.bar2.html'
22+
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar2() -> Inner'
23+
pub fn bar2() -> crate::bar::Inner {
24+
Alias
25+
}
26+
27+
// It's a non-public, so it doesn't appear in documentation so it should not be visible.
28+
// @has 'foo/fn.bar3.html'
29+
// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar3() -> Bar'
30+
pub fn bar3() -> CrateAlias {
31+
Alias
32+
}

0 commit comments

Comments
 (0)