Skip to content

Commit

Permalink
Unrolled build for rust-lang#124149
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rust-timer authored Apr 19, 2024
2 parents ce3263e + 2e7d9e9 commit c3ab69a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
21 changes: 11 additions & 10 deletions src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -1464,16 +1464,7 @@ function initSearch(rawSearchIndex) {
return 0;
});

const transformed = transformResults(result_list);
const descs = await Promise.all(transformed.map(result => {
return searchIndexEmptyDesc.get(result.crate).contains(result.bitIndex) ?
"" :
searchState.loadDesc(result);
}));
for (const [i, result] of transformed.entries()) {
result.desc = descs[i];
}
return transformed;
return transformResults(result_list);
}

/**
Expand Down Expand Up @@ -2517,6 +2508,16 @@ function initSearch(rawSearchIndex) {
sorted_others,
parsedQuery);
handleAliases(ret, parsedQuery.original.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 => {
return searchIndexEmptyDesc.get(result.crate).contains(result.bitIndex) ?
"" :
searchState.loadDesc(result);
}));
for (const [i, result] of list.entries()) {
result.desc = descs[i];
}
}));
if (parsedQuery.error !== null && ret.others.length !== 0) {
// It means some doc aliases were found so let's "remove" the error!
ret.query.error = null;
Expand Down
6 changes: 5 additions & 1 deletion tests/rustdoc-js-std/alias-1.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const EXPECTED = {
'query': '&',
'others': [
{ 'path': 'std', 'name': 'reference' },
{
'path': 'std',
'name': 'reference',
'desc': "References, <code>&amp;T</code> and <code>&amp;mut T</code>.",
},
],
};

0 comments on commit c3ab69a

Please sign in to comment.