Skip to content

Commit 0feb8de

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 3b703c9 commit 0feb8de

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,9 @@ function initSearch(rawSearchIndex) {
15741574
for (const nested of fnType.generics) {
15751575
writeFn(nested, where);
15761576
}
1577-
whereClause.set(fnParamNames[-1 - fnType.id], where);
1577+
if (where.length > 0) {
1578+
whereClause.set(fnParamNames[-1 - fnType.id], where);
1579+
}
15781580
} else {
15791581
if (fnType.ty === TY_PRIMITIVE) {
15801582
if (fnType.id === typeNameIdOfArray || fnType.id === typeNameIdOfSlice ||

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)