Rollup merge of #116475 - notriddle:notriddle/impl-trait-null, r=GuillaumeGomez

rustdoc-search: fix bug with multi-item impl trait

Preview searches:

- https://notriddle.com/rustdoc-html-demo-5/compiler-doc-impl-trait-bugfix/index.html?search=-%3E%20globalctxt

- https://notriddle.com/rustdoc-html-demo-5/compiler-doc-impl-trait-bugfix/index.html?search=globalctxt
This commit is contained in:
Guillaume Gomez 2023-10-06 13:18:35 +02:00 committed by GitHub
commit 5674092e76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 6 deletions

View File

@ -1555,7 +1555,7 @@ function initSearch(rawSearchIndex) {
return false; return false;
} }
} }
} else if (fnType.id !== null) { } else {
if (queryElem.id === typeNameIdOfArrayOrSlice && if (queryElem.id === typeNameIdOfArrayOrSlice &&
(fnType.id === typeNameIdOfSlice || fnType.id === typeNameIdOfArray) (fnType.id === typeNameIdOfSlice || fnType.id === typeNameIdOfArray)
) { ) {

View File

@ -1,3 +1,4 @@
// exact-check
// ignore-order // ignore-order
const EXPECTED = [ const EXPECTED = [
@ -20,9 +21,16 @@ const EXPECTED = [
{ {
'query': '-> Aaaaaaa', 'query': '-> Aaaaaaa',
'others': [ 'others': [
{ 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
{ 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' },
{ 'path': 'impl_trait', 'name': 'bbbbbbb' }, { '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' }, { 'path': 'impl_trait', 'name': 'Aaaaaaa' },
], ],
'in_args': [ 'in_args': [
{ 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
{ 'path': 'impl_trait::Ccccccc', 'name': 'eeeeeee' }, { 'path': 'impl_trait::Ccccccc', 'name': 'eeeeeee' },
{ 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
], ],
'returned': [ 'returned': [
{ 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
{ 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' },
{ 'path': 'impl_trait', 'name': 'bbbbbbb' }, { 'path': 'impl_trait', 'name': 'bbbbbbb' },
{ 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' },
{ 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
{ 'path': 'impl_trait::Ccccccc', 'name': 'ggggggg' },
], ],
}, },
]; ];

View File

@ -1,6 +1,9 @@
pub trait Aaaaaaa {} pub trait Aaaaaaa {}
pub trait Bbbbbbb {}
impl Aaaaaaa for () {} impl Aaaaaaa for () {}
impl Bbbbbbb for () {}
pub fn bbbbbbb() -> impl Aaaaaaa { pub fn bbbbbbb() -> impl Aaaaaaa {
() ()
@ -18,4 +21,7 @@ impl Ccccccc {
pub fn fffffff(&self, x: impl Aaaaaaa) -> impl Aaaaaaa { pub fn fffffff(&self, x: impl Aaaaaaa) -> impl Aaaaaaa {
x x
} }
pub fn ggggggg(&self) -> impl Aaaaaaa + Bbbbbbb {
()
}
} }