Skip to content

Commit 89a4c7f

Browse files
committed
rustdoc: bug fix for -> option<t>
1 parent b6bb06c commit 89a4c7f

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/librustdoc/html/static/js/externs.js

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ let ParserState;
3737
* args: Array<QueryElement>,
3838
* returned: Array<QueryElement>,
3939
* foundElems: number,
40+
* totalElems: number,
4041
* literalSearch: boolean,
4142
* corrections: Array<{from: string, to: integer}>,
4243
* }}

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,8 @@ function initSearch(rawSearchIndex) {
973973
returned: [],
974974
// Total number of "top" elements (does not include generics).
975975
foundElems: 0,
976+
// Total number of elements (includes generics).
977+
totalElems: 0,
976978
literalSearch: false,
977979
error: null,
978980
correction: null,
@@ -1074,6 +1076,7 @@ function initSearch(rawSearchIndex) {
10741076
query.literalSearch = parserState.totalElems > 1;
10751077
}
10761078
query.foundElems = query.elems.length + query.returned.length;
1079+
query.totalElems = parserState.totalElems;
10771080
return query;
10781081
}
10791082

@@ -1980,7 +1983,7 @@ function initSearch(rawSearchIndex) {
19801983
}
19811984
elem.id = match;
19821985
}
1983-
if ((elem.id === null && parsedQuery.foundElems > 1 && elem.typeFilter === -1)
1986+
if ((elem.id === null && parsedQuery.totalElems > 1 && elem.typeFilter === -1)
19841987
|| elem.typeFilter === TY_GENERIC) {
19851988
if (genericSymbols.has(elem.name)) {
19861989
elem.id = genericSymbols.get(elem.name);

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

+6
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,10 @@ const EXPECTED = [
7272
{ 'path': 'std::option::Option', 'name': 'flatten' },
7373
],
7474
},
75+
{
76+
'query': 'option<t>',
77+
'returned': [
78+
{ 'path': 'std::result::Result', 'name': 'ok' },
79+
],
80+
},
7581
];

0 commit comments

Comments
 (0)