Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
) {
Expand Down
19 changes: 14 additions & 5 deletions tests/rustdoc-js/impl-trait.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// exact-check
// ignore-order

const EXPECTED = [
Expand All @@ -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' },
],
},
{
Expand All @@ -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' },
],
},
];
6 changes: 6 additions & 0 deletions tests/rustdoc-js/impl-trait.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
pub trait Aaaaaaa {}

pub trait Bbbbbbb {}

impl Aaaaaaa for () {}
impl Bbbbbbb for () {}

pub fn bbbbbbb() -> impl Aaaaaaa {
()
Expand All @@ -18,4 +21,7 @@ impl Ccccccc {
pub fn fffffff(&self, x: impl Aaaaaaa) -> impl Aaaaaaa {
x
}
pub fn ggggggg(&self) -> impl Aaaaaaa + Bbbbbbb {
()
}
}
Loading