Skip to content

Commit ee3ee04

Browse files
committed
rustdoc-search: fix where clause highlight with dup generics
Essentially, the unifier only adds generics to a parameter when a part of its where clause is highlighted. To make that work, the formatter can ignore the empties.
1 parent bccb9f7 commit ee3ee04

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/librustdoc/html/static/js/search.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,9 @@ function initSearch(rawSearchIndex) {
15721572
for (const nested of fnType.generics) {
15731573
writeFn(nested, where);
15741574
}
1575-
whereClause.set(fnParamNames[-1 - fnType.id], where);
1575+
if (where.length > 0) {
1576+
whereClause.set(fnParamNames[-1 - fnType.id], where);
1577+
}
15761578
} else {
15771579
if (fnType.ty === TY_PRIMITIVE) {
15781580
if (fnType.id === typeNameIdOfArray || fnType.id === typeNameIdOfSlice ||
@@ -2913,7 +2915,7 @@ function initSearch(rawSearchIndex) {
29132915
sorted_returned,
29142916
sorted_others,
29152917
parsedQuery);
2916-
await handleAliases(ret, parsedQuery.original.replace(/"/g, ""),
2918+
await handleAliases(ret, parsedQuery.userQuery.replace(/"/g, ""),
29172919
filterCrates, currentCrate);
29182920
await Promise.all([ret.others, ret.returned, ret.in_args].map(async list => {
29192921
const descs = await Promise.all(list.map(result => {

tests/rustdoc-js-std/vec-type-signatures.js

+12
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,16 @@ const EXPECTED = [
1919
{ 'path': 'std::vec::IntoIter', 'name': 'next_chunk' },
2020
],
2121
},
22+
{
23+
'query': 'vec<Allocator> -> Box<[T]>',
24+
'others': [
25+
{
26+
'path': 'std::boxed::Box',
27+
'name': 'from',
28+
'displayType': '`Vec`<T, `A`> -> `Box`<`[T]`, A>',
29+
'displayMappedNames': `T = T`,
30+
'displayWhereClause': 'A: `Allocator`',
31+
},
32+
],
33+
},
2234
];

0 commit comments

Comments
 (0)