Skip to content

Rustdoc anonymous reexports #97617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
@@ -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) => {
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;