Skip to content
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
23 changes: 13 additions & 10 deletions src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -4749,11 +4749,16 @@ class DocSearch {
})(),
"query": parsedQuery,
};
} else if (parsedQuery.error !== null) {
} else if (parsedQuery.error !== null || parsedQuery.foundElems === 0) {
// Symbol-only queries like `==` do not parse into type elements,
// but can still match exact item names or doc aliases.
const others = parsedQuery.userQuery.length === 0 ?
(async function*() {})() :
innerRunNameQuery(currentCrate);
return {
"in_args": (async function*() {})(),
"returned": (async function*() {})(),
"others": innerRunNameQuery(currentCrate),
"others": others,
"query": parsedQuery,
};
} else {
Expand All @@ -4764,14 +4769,12 @@ class DocSearch {
return {
"in_args": (async function*() {})(),
"returned": (async function*() {})(),
"others": parsedQuery.foundElems === 0 ?
(async function*() {})() :
innerRunTypeQuery(
parsedQuery.elems,
parsedQuery.returned,
typeInfo,
currentCrate,
),
"others": innerRunTypeQuery(
parsedQuery.elems,
parsedQuery.returned,
typeInfo,
currentCrate,
),
"query": parsedQuery,
};
}
Expand Down
24 changes: 24 additions & 0 deletions tests/rustdoc-js-std/doc-alias-symbols-150921.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// exact-check
// Regression test for <https://github.com/rust-lang/rust/issues/150921>.

const EXPECTED = [
{
'query': '==',
'others': [
{
'path': 'std::cmp',
'name': 'Eq',
'alias': '==',
'href': '../std/cmp/trait.Eq.html',
'is_alias': true,
},
{
'path': 'std::cmp',
'name': 'PartialEq',
'alias': '==',
'href': '../std/cmp/trait.PartialEq.html',
'is_alias': true,
},
],
},
];
29 changes: 29 additions & 0 deletions tests/rustdoc-js/doc-alias-symbols-150921.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// exact-check
// Regression test for <https://github.com/rust-lang/rust/issues/150921>.

const EXPECTED = [
{
'query': '==',
'others': [
{
'path': 'doc_alias_symbols_150921',
'name': 'OperatorEqEqAlias',
'alias': '==',
'href': '../doc_alias_symbols_150921/struct.OperatorEqEqAlias.html',
'is_alias': true,
},
],
},
{
'query': '!=',
'others': [
{
'path': 'doc_alias_symbols_150921',
'name': 'OperatorNotEqAlias',
'alias': '!=',
'href': '../doc_alias_symbols_150921/struct.OperatorNotEqAlias.html',
'is_alias': true,
},
],
},
];
7 changes: 7 additions & 0 deletions tests/rustdoc-js/doc-alias-symbols-150921.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Regression test for <https://github.com/rust-lang/rust/issues/150921>.

#[doc(alias = "==")]
pub struct OperatorEqEqAlias;

#[doc(alias = "!=")]
pub struct OperatorNotEqAlias;
Loading