about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2023-02-19 13:03:42 +0530
committerGitHub <noreply@github.com>2023-02-19 13:03:42 +0530
commit636679ecd63a083cd2e3931a77f8a469a8c57c85 (patch)
treebc491537c436f461d373737709f3c18a49e429e1
parent0257e288f54e9935e1554ffb081def6ef57befe8 (diff)
parent0e3ae605bc245e0fb25e04c5f99d398d8a2b5c09 (diff)
downloadrust-636679ecd63a083cd2e3931a77f8a469a8c57c85.tar.gz
rust-636679ecd63a083cd2e3931a77f8a469a8c57c85.zip
Rollup merge of #108146 - notriddle:notriddle/rustdoc-search-reference, r=GuillaumeGomez
rustdoc: hide `reference` methods in search index

They're hidden in the HTML, so it makes no sense in the search engine for `reference::next` or `reference::shrink` to be shown.

https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/What.20is.20.60reference.3A.3Ashrink.60.3F
-rw-r--r--src/librustdoc/formats/cache.rs10
-rw-r--r--tests/rustdoc-js-std/reference-shrink.js8
2 files changed, 18 insertions, 0 deletions
diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs
index 68bdd2bc531..8dbfaf4bbc9 100644
--- a/src/librustdoc/formats/cache.rs
+++ b/src/librustdoc/formats/cache.rs
@@ -287,6 +287,16 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
                     } else {
                         let last = self.cache.parent_stack.last().expect("parent_stack is empty 2");
                         let did = match &*last {
+                            ParentStackItem::Impl {
+                                // impl Trait for &T { fn method(self); }
+                                //
+                                // When generating a function index with the above shape, we want it
+                                // associated with `T`, not with the primitive reference type. It should
+                                // show up as `T::method`, rather than `reference::method`, in the search
+                                // results page.
+                                for_: clean::Type::BorrowedRef { type_, .. },
+                                ..
+                            } => type_.def_id(&self.cache),
                             ParentStackItem::Impl { for_, .. } => for_.def_id(&self.cache),
                             ParentStackItem::Type(item_id) => item_id.as_def_id(),
                         };
diff --git a/tests/rustdoc-js-std/reference-shrink.js b/tests/rustdoc-js-std/reference-shrink.js
new file mode 100644
index 00000000000..f90be6d1bfd
--- /dev/null
+++ b/tests/rustdoc-js-std/reference-shrink.js
@@ -0,0 +1,8 @@
+// exact-check
+
+const QUERY = 'reference::shrink';
+
+const EXPECTED = {
+    // avoid including the method that's not going to be in the HTML
+    'others': [],
+};