about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNoah Lev <camelidcamel@gmail.com>2024-08-01 23:20:20 -0700
committerNoah Lev <camelidcamel@gmail.com>2024-08-02 17:59:52 -0700
commit2721e97c5d9a4e5a001461e499a751e81e10df4c (patch)
tree26e3a4a894d8b3a7e5d8e7dd95d712b0c228af98
parent7dd5ad282c4aab165236c8ba9404929d7dd337ac (diff)
downloadrust-2721e97c5d9a4e5a001461e499a751e81e10df4c.tar.gz
rust-2721e97c5d9a4e5a001461e499a751e81e10df4c.zip
rustdoc: Clarify construction of name for search index
-rw-r--r--src/librustdoc/formats/cache.rs25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs
index 8c0ed6cddf0..13b91f483eb 100644
--- a/src/librustdoc/formats/cache.rs
+++ b/src/librustdoc/formats/cache.rs
@@ -260,17 +260,20 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
         }
 
         // Index this method for searching later on.
-        if let Some(name) = item.name.or_else(|| {
-            if item.is_stripped() {
-                None
-            } else if let clean::ImportItem(ref i) = *item.kind
-                && let clean::ImportKind::Simple(s) = i.kind
-            {
-                Some(s)
-            } else {
-                None
-            }
-        }) {
+        let search_name = if !item.is_stripped() {
+            item.name.or_else(|| {
+                if let clean::ImportItem(ref i) = *item.kind
+                    && let clean::ImportKind::Simple(s) = i.kind
+                {
+                    Some(s)
+                } else {
+                    None
+                }
+            })
+        } else {
+            None
+        };
+        if let Some(name) = search_name {
             add_item_to_search_index(self.tcx, &mut self.cache, &item, name)
         }