Skip to content

Commit 636679e

Browse files
authored
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
2 parents 0257e28 + 0e3ae60 commit 636679e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/librustdoc/formats/cache.rs

+10
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,16 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
287287
} else {
288288
let last = self.cache.parent_stack.last().expect("parent_stack is empty 2");
289289
let did = match &*last {
290+
ParentStackItem::Impl {
291+
// impl Trait for &T { fn method(self); }
292+
//
293+
// When generating a function index with the above shape, we want it
294+
// associated with `T`, not with the primitive reference type. It should
295+
// show up as `T::method`, rather than `reference::method`, in the search
296+
// results page.
297+
for_: clean::Type::BorrowedRef { type_, .. },
298+
..
299+
} => type_.def_id(&self.cache),
290300
ParentStackItem::Impl { for_, .. } => for_.def_id(&self.cache),
291301
ParentStackItem::Type(item_id) => item_id.as_def_id(),
292302
};
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// exact-check
2+
3+
const QUERY = 'reference::shrink';
4+
5+
const EXPECTED = {
6+
// avoid including the method that's not going to be in the HTML
7+
'others': [],
8+
};

0 commit comments

Comments
 (0)