diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index e1818dab1d5a1..e565b559be8f6 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -1572,7 +1572,9 @@ function initSearch(rawSearchIndex) { for (const nested of fnType.generics) { writeFn(nested, where); } - whereClause.set(fnParamNames[-1 - fnType.id], where); + if (where.length > 0) { + whereClause.set(fnParamNames[-1 - fnType.id], where); + } } else { if (fnType.ty === TY_PRIMITIVE) { if (fnType.id === typeNameIdOfArray || fnType.id === typeNameIdOfSlice || @@ -2913,7 +2915,7 @@ function initSearch(rawSearchIndex) { sorted_returned, sorted_others, parsedQuery); - await handleAliases(ret, parsedQuery.original.replace(/"/g, ""), + await handleAliases(ret, parsedQuery.userQuery.replace(/"/g, ""), filterCrates, currentCrate); await Promise.all([ret.others, ret.returned, ret.in_args].map(async list => { const descs = await Promise.all(list.map(result => { diff --git a/tests/rustdoc-js-std/parser-errors.js b/tests/rustdoc-js-std/parser-errors.js index 54b4501202634..db810633f9cd2 100644 --- a/tests/rustdoc-js-std/parser-errors.js +++ b/tests/rustdoc-js-std/parser-errors.js @@ -195,7 +195,6 @@ const PARSED = [ query: "a:b", elems: [], foundElems: 0, - original: "a:b", returned: [], userQuery: "a:b", error: "Unknown type filter `a`", diff --git a/tests/rustdoc-js-std/vec-type-signatures.js b/tests/rustdoc-js-std/vec-type-signatures.js index 18cf9d6efd0fd..4e93caf53beeb 100644 --- a/tests/rustdoc-js-std/vec-type-signatures.js +++ b/tests/rustdoc-js-std/vec-type-signatures.js @@ -19,4 +19,16 @@ const EXPECTED = [ { 'path': 'std::vec::IntoIter', 'name': 'next_chunk' }, ], }, + { + 'query': 'vec -> Box<[T]>', + 'others': [ + { + 'path': 'std::boxed::Box', + 'name': 'from', + 'displayType': '`Vec` -> `Box`<`[T]`, A>', + 'displayMappedNames': `T = T`, + 'displayWhereClause': 'A: `Allocator`', + }, + ], + }, ]; diff --git a/tests/rustdoc-js/non-english-identifier.js b/tests/rustdoc-js/non-english-identifier.js index 1765a69152a8f..86ba1b9dadda1 100644 --- a/tests/rustdoc-js/non-english-identifier.js +++ b/tests/rustdoc-js/non-english-identifier.js @@ -11,14 +11,13 @@ const PARSED = [ }], returned: [], foundElems: 1, - original: "中文", userQuery: "中文", error: null, }, { query: '_0Mixed中英文', elems: [{ - name: "_0mixed中英文", + name: "_0Mixed中英文", fullPath: ["_0mixed中英文"], pathWithoutLast: [], pathLast: "_0mixed中英文", @@ -26,15 +25,14 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "_0Mixed中英文", returned: [], - userQuery: "_0mixed中英文", + userQuery: "_0Mixed中英文", error: null, }, { query: 'my_crate::中文API', elems: [{ - name: "my_crate::中文api", + name: "my_crate::中文API", fullPath: ["my_crate", "中文api"], pathWithoutLast: ["my_crate"], pathLast: "中文api", @@ -42,26 +40,25 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "my_crate::中文API", returned: [], - userQuery: "my_crate::中文api", + userQuery: "my_crate::中文APIi", error: null, }, { query: '类型A,类型B<约束C>->返回类型<关联类型=路径::约束D>', elems: [{ - name: "类型a", + name: "类型A", fullPath: ["类型a"], pathWithoutLast: [], pathLast: "类型a", generics: [], }, { - name: "类型b", + name: "类型B", fullPath: ["类型b"], pathWithoutLast: [], pathLast: "类型b", generics: [{ - name: "约束c", + name: "约束C", fullPath: ["约束c"], pathWithoutLast: [], pathLast: "约束c", @@ -71,7 +68,6 @@ const PARSED = [ foundElems: 3, totalElems: 5, literalSearch: true, - original: "类型A,类型B<约束C>->返回类型<关联类型=路径::约束D>", returned: [{ name: "返回类型", fullPath: ["返回类型"], @@ -79,7 +75,7 @@ const PARSED = [ pathLast: "返回类型", generics: [], }], - userQuery: "类型a,类型b<约束c>->返回类型<关联类型=路径::约束d>", + userQuery: "类型A,类型B<约束C>->返回类型<关联类型=路径::约束D>", error: null, }, { @@ -93,7 +89,6 @@ const PARSED = [ typeFilter: 16, }], foundElems: 1, - original: "my_crate 中文宏!", returned: [], userQuery: "my_crate 中文宏!", error: null, @@ -102,7 +97,6 @@ const PARSED = [ query: '非法符号——', elems: [], foundElems: 0, - original: "非法符号——", returned: [], userQuery: "非法符号——", error: "Unexpected `—` after `号` (not a valid identifier)",