about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-04-10 11:10:13 +0200
committerGitHub <noreply@github.com>2025-04-10 11:10:13 +0200
commit070148acf1ad6e33f1e07a4e9f7171d6048c5648 (patch)
treed61155afa6dab31aa1e498cad4a2175470720c5d
parent9d28fe39763974a96d61232e96ac856735e4cdd6 (diff)
parenta11fbeec1fc0ad1b8c8814dd2fa4704c4d5e8e0e (diff)
downloadrust-070148acf1ad6e33f1e07a4e9f7171d6048c5648.tar.gz
rust-070148acf1ad6e33f1e07a4e9f7171d6048c5648.zip
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 https://github.com/rust-lang/rust/pull/137534. It doesn't change anything about the performance issue.

r? ```@notriddle```
-rw-r--r--src/librustdoc/passes/strip_hidden.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/librustdoc/passes/strip_hidden.rs b/src/librustdoc/passes/strip_hidden.rs
index bcdca862862..692ce21d6cf 100644
--- a/src/librustdoc/passes/strip_hidden.rs
+++ b/src/librustdoc/passes/strip_hidden.rs
@@ -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;
+                }
             }
         }