Skip to content

Commit

Permalink
Rollup merge of #97617 - GuillaumeGomez:rustdoc-anonymous-reexports, …
Browse files Browse the repository at this point in the history
…r=Nemo157

Rustdoc anonymous reexports

Fixes #97615.

r? `@Nemo157`
  • Loading branch information
Dylan-DPC committed Jun 2, 2022
2 parents f22f743 + 1d12b7e commit f95e2d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
22 changes: 22 additions & 0 deletions src/test/rustdoc/anonymous-reexport.rs
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit f95e2d3

Please sign in to comment.