Skip to content

Commit abd105d

Browse files
authored
Rollup merge of rust-lang#124149 - notriddle:notriddle/desc-alias, r=GuillaumeGomez
rustdoc-search: fix description on aliases in results This needs to start downloading the descriptions after aliases have been added to the result set.
2 parents c1f2ed1 + 2e7d9e9 commit abd105d

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

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

+11-10
Original file line numberDiff line numberDiff line change
@@ -1464,16 +1464,7 @@ function initSearch(rawSearchIndex) {
14641464
return 0;
14651465
});
14661466

1467-
const transformed = transformResults(result_list);
1468-
const descs = await Promise.all(transformed.map(result => {
1469-
return searchIndexEmptyDesc.get(result.crate).contains(result.bitIndex) ?
1470-
"" :
1471-
searchState.loadDesc(result);
1472-
}));
1473-
for (const [i, result] of transformed.entries()) {
1474-
result.desc = descs[i];
1475-
}
1476-
return transformed;
1467+
return transformResults(result_list);
14771468
}
14781469

14791470
/**
@@ -2517,6 +2508,16 @@ function initSearch(rawSearchIndex) {
25172508
sorted_others,
25182509
parsedQuery);
25192510
handleAliases(ret, parsedQuery.original.replace(/"/g, ""), filterCrates, currentCrate);
2511+
await Promise.all([ret.others, ret.returned, ret.in_args].map(async list => {
2512+
const descs = await Promise.all(list.map(result => {
2513+
return searchIndexEmptyDesc.get(result.crate).contains(result.bitIndex) ?
2514+
"" :
2515+
searchState.loadDesc(result);
2516+
}));
2517+
for (const [i, result] of list.entries()) {
2518+
result.desc = descs[i];
2519+
}
2520+
}));
25202521
if (parsedQuery.error !== null && ret.others.length !== 0) {
25212522
// It means some doc aliases were found so let's "remove" the error!
25222523
ret.query.error = null;

tests/rustdoc-js-std/alias-1.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
const EXPECTED = {
22
'query': '&',
33
'others': [
4-
{ 'path': 'std', 'name': 'reference' },
4+
{
5+
'path': 'std',
6+
'name': 'reference',
7+
'desc': "References, <code>&amp;T</code> and <code>&amp;mut T</code>.",
8+
},
59
],
610
};

0 commit comments

Comments
 (0)