about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-06-02 15:27:00 +0200
committerGitHub <noreply@github.com>2022-06-02 15:27:00 +0200
commitf95e2d34c3926c13ab9cfaee451cc12504808b86 (patch)
tree45ff89db9b5eaebae08939d65ea27289983a6d6c /src
parentf22f7431c26b224d555d4bae8eedb7218f6bfddb (diff)
parent1d12b7eb2992cd40485e638c9dde01bbf194dffb (diff)
downloadrust-f95e2d34c3926c13ab9cfaee451cc12504808b86.tar.gz
rust-f95e2d34c3926c13ab9cfaee451cc12504808b86.zip
Rollup merge of #97617 - GuillaumeGomez:rustdoc-anonymous-reexports, r=Nemo157
Rustdoc anonymous reexports

Fixes #97615.

r? `@Nemo157`
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/visit_ast.rs4
-rw-r--r--src/test/rustdoc/anonymous-reexport.rs22
2 files changed, 24 insertions, 2 deletions
diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs
index d57868caf7a..00553d3f007 100644
--- a/src/librustdoc/visit_ast.rs
+++ b/src/librustdoc/visit_ast.rs
@@ -286,8 +286,8 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
                     self.visit_foreign_item(item, None, om);
                 }
             }
-            // If we're inlining, skip private items.
-            _ if self.inlining && !is_pub => {}
+            // If we're inlining, skip private items or item reexported as "_".
+            _ if self.inlining && (!is_pub || renamed == Some(kw::Underscore)) => {}
             hir::ItemKind::GlobalAsm(..) => {}
             hir::ItemKind::Use(_, hir::UseKind::ListStem) => {}
             hir::ItemKind::Use(path, kind) => {
diff --git a/src/test/rustdoc/anonymous-reexport.rs b/src/test/rustdoc/anonymous-reexport.rs
new file mode 100644
index 00000000000..6b884ff14df
--- /dev/null
+++ b/src/test/rustdoc/anonymous-reexport.rs
@@ -0,0 +1,22 @@
+#![crate_name = "foo"]
+
+// This test ensures we don't display anonymous (non-inline) re-exports of public items.
+
+// @has 'foo/index.html'
+// @has - '//*[@id="main-content"]' ''
+// We check that the only "h2" present is for "Bla".
+// @count - '//*[@id="main-content"]/h2' 1
+// @has - '//*[@id="main-content"]/h2' 'Structs'
+// @count - '//*[@id="main-content"]//a[@class="struct"]' 1
+
+mod ext {
+    pub trait Foo {}
+    pub trait Bar {}
+    pub struct S;
+}
+
+pub use crate::ext::Foo as _;
+pub use crate::ext::Bar as _;
+pub use crate::ext::S as _;
+
+pub struct Bla;