From 1eb2a766417c755f6787358bfc36385a26c4ed31 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 5 Oct 2023 22:32:37 -0700 Subject: [PATCH] rustdoc-search: fix bug with multi-item impl trait --- src/librustdoc/html/static/js/search.js | 2 +- tests/rustdoc-js/impl-trait.js | 19 ++++++++++++++----- tests/rustdoc-js/impl-trait.rs | 6 ++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 2f0cae0a48e21..7a282a99e9ce9 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -1555,7 +1555,7 @@ function initSearch(rawSearchIndex) { return false; } } - } else if (fnType.id !== null) { + } else { if (queryElem.id === typeNameIdOfArrayOrSlice && (fnType.id === typeNameIdOfSlice || fnType.id === typeNameIdOfArray) ) { diff --git a/tests/rustdoc-js/impl-trait.js b/tests/rustdoc-js/impl-trait.js index 710e594b54774..00d67d639bd08 100644 --- a/tests/rustdoc-js/impl-trait.js +++ b/tests/rustdoc-js/impl-trait.js @@ -1,3 +1,4 @@ +// exact-check // ignore-order const EXPECTED = [ @@ -20,9 +21,16 @@ const EXPECTED = [ { 'query': '-> Aaaaaaa', 'others': [ - { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' }, - { 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' }, { 'path': 'impl_trait', 'name': 'bbbbbbb' }, + { 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' }, + { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' }, + { 'path': 'impl_trait::Ccccccc', 'name': 'ggggggg' }, + ], + }, + { + 'query': '-> Bbbbbbb', + 'others': [ + { 'path': 'impl_trait::Ccccccc', 'name': 'ggggggg' }, ], }, { @@ -31,13 +39,14 @@ const EXPECTED = [ { 'path': 'impl_trait', 'name': 'Aaaaaaa' }, ], 'in_args': [ - { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' }, { 'path': 'impl_trait::Ccccccc', 'name': 'eeeeeee' }, + { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' }, ], 'returned': [ - { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' }, - { 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' }, { 'path': 'impl_trait', 'name': 'bbbbbbb' }, + { 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' }, + { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' }, + { 'path': 'impl_trait::Ccccccc', 'name': 'ggggggg' }, ], }, ]; diff --git a/tests/rustdoc-js/impl-trait.rs b/tests/rustdoc-js/impl-trait.rs index fb8869b46f3d4..d20fdd60ec965 100644 --- a/tests/rustdoc-js/impl-trait.rs +++ b/tests/rustdoc-js/impl-trait.rs @@ -1,6 +1,9 @@ pub trait Aaaaaaa {} +pub trait Bbbbbbb {} + impl Aaaaaaa for () {} +impl Bbbbbbb for () {} pub fn bbbbbbb() -> impl Aaaaaaa { () @@ -18,4 +21,7 @@ impl Ccccccc { pub fn fffffff(&self, x: impl Aaaaaaa) -> impl Aaaaaaa { x } + pub fn ggggggg(&self) -> impl Aaaaaaa + Bbbbbbb { + () + } }