Skip to content

Small code improvement in rustdoc hidden stripper #138167

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
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
22 changes: 12 additions & 10 deletions src/librustdoc/passes/strip_hidden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,21 @@ impl DocFolder for Stripper<'_, '_> {

if let clean::ImportItem(clean::Import { source, .. }) = &i.kind
&& let Some(source_did) = source.did
&& let Some(import_def_id) = i.def_id().and_then(|def_id| def_id.as_local())
{
let reexports = reexport_chain(self.tcx, import_def_id, source_did);
if self.tcx.is_doc_hidden(source_did) {
return None;
} else if let Some(import_def_id) = i.def_id().and_then(|def_id| def_id.as_local()) {
let reexports = reexport_chain(self.tcx, import_def_id, source_did);

// Check if any reexport in the chain has a hidden source
let has_hidden_source = reexports
.iter()
.filter_map(|reexport| reexport.id())
.any(|reexport_did| self.tcx.is_doc_hidden(reexport_did))
|| self.tcx.is_doc_hidden(source_did);
// Check if any reexport in the chain has a hidden source
let has_hidden_source = reexports
.iter()
.filter_map(|reexport| reexport.id())
.any(|reexport_did| self.tcx.is_doc_hidden(reexport_did));

if has_hidden_source {
return None;
if has_hidden_source {
return None;
}
}
}

Expand Down
Loading