Skip to content

Commit 070148a

Browse files
authored
Rollup merge of #138167 - GuillaumeGomez:rustdoc-hidden-stripper-improvement, r=camelid
Small code improvement in rustdoc hidden stripper This is a very minor code improvement following #137534. It doesn't change anything about the performance issue. r? ```@notriddle```
2 parents 9d28fe3 + a11fbee commit 070148a

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/librustdoc/passes/strip_hidden.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,21 @@ impl DocFolder for Stripper<'_, '_> {
9191

9292
if let clean::ImportItem(clean::Import { source, .. }) = &i.kind
9393
&& let Some(source_did) = source.did
94-
&& let Some(import_def_id) = i.def_id().and_then(|def_id| def_id.as_local())
9594
{
96-
let reexports = reexport_chain(self.tcx, import_def_id, source_did);
95+
if self.tcx.is_doc_hidden(source_did) {
96+
return None;
97+
} else if let Some(import_def_id) = i.def_id().and_then(|def_id| def_id.as_local()) {
98+
let reexports = reexport_chain(self.tcx, import_def_id, source_did);
9799

98-
// Check if any reexport in the chain has a hidden source
99-
let has_hidden_source = reexports
100-
.iter()
101-
.filter_map(|reexport| reexport.id())
102-
.any(|reexport_did| self.tcx.is_doc_hidden(reexport_did))
103-
|| self.tcx.is_doc_hidden(source_did);
100+
// Check if any reexport in the chain has a hidden source
101+
let has_hidden_source = reexports
102+
.iter()
103+
.filter_map(|reexport| reexport.id())
104+
.any(|reexport_did| self.tcx.is_doc_hidden(reexport_did));
104105

105-
if has_hidden_source {
106-
return None;
106+
if has_hidden_source {
107+
return None;
108+
}
107109
}
108110
}
109111

0 commit comments

Comments
 (0)