Skip to content

Commit f95e2d3

Browse files
authored
Rollup merge of #97617 - GuillaumeGomez:rustdoc-anonymous-reexports, r=Nemo157
Rustdoc anonymous reexports Fixes #97615. r? `@Nemo157`
2 parents f22f743 + 1d12b7e commit f95e2d3

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

Diff for: src/librustdoc/visit_ast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
286286
self.visit_foreign_item(item, None, om);
287287
}
288288
}
289-
// If we're inlining, skip private items.
290-
_ if self.inlining && !is_pub => {}
289+
// If we're inlining, skip private items or item reexported as "_".
290+
_ if self.inlining && (!is_pub || renamed == Some(kw::Underscore)) => {}
291291
hir::ItemKind::GlobalAsm(..) => {}
292292
hir::ItemKind::Use(_, hir::UseKind::ListStem) => {}
293293
hir::ItemKind::Use(path, kind) => {

Diff for: src/test/rustdoc/anonymous-reexport.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#![crate_name = "foo"]
2+
3+
// This test ensures we don't display anonymous (non-inline) re-exports of public items.
4+
5+
// @has 'foo/index.html'
6+
// @has - '//*[@id="main-content"]' ''
7+
// We check that the only "h2" present is for "Bla".
8+
// @count - '//*[@id="main-content"]/h2' 1
9+
// @has - '//*[@id="main-content"]/h2' 'Structs'
10+
// @count - '//*[@id="main-content"]//a[@class="struct"]' 1
11+
12+
mod ext {
13+
pub trait Foo {}
14+
pub trait Bar {}
15+
pub struct S;
16+
}
17+
18+
pub use crate::ext::Foo as _;
19+
pub use crate::ext::Bar as _;
20+
pub use crate::ext::S as _;
21+
22+
pub struct Bla;

0 commit comments

Comments
 (0)