Skip to content

Commit f8afb63

Browse files
authored
Rollup merge of #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 26d4b1b + 2e7d9e9 commit f8afb63

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,16 +1464,7 @@ function initSearch(rawSearchIndex) {
14641464
return0;
14651465
});
14661466

1467-
consttransformed=transformResults(result_list);
1468-
constdescs=awaitPromise.all(transformed.map(result=>{
1469-
returnsearchIndexEmptyDesc.get(result.crate).contains(result.bitIndex) ?
1470-
"" :
1471-
searchState.loadDesc(result);
1472-
}));
1473-
for(const[i,result]oftransformed.entries()){
1474-
result.desc=descs[i];
1475-
}
1476-
returntransformed;
1467+
returntransformResults(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+
awaitPromise.all([ret.others,ret.returned,ret.in_args].map(asynclist=>{
2512+
constdescs=awaitPromise.all(list.map(result=>{
2513+
returnsearchIndexEmptyDesc.get(result.crate).contains(result.bitIndex) ?
2514+
"" :
2515+
searchState.loadDesc(result);
2516+
}));
2517+
for(const[i,result]oflist.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‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
constEXPECTED={
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)