Skip to content

Commit 2a391e9

Browse files
authored
Rollup merge of rust-lang#149332 - asukaminato0721:149324, r=GuillaumeGomez
fix rustdoc search says “Consider searching for "null" instead.” rust-lang#149324 fix rust-lang#149324 Now builds the “generic parameter” correction banner from discrete sentence fragments and appends the “Consider searching …” clause only when query.proposeCorrectionTo is non-null, so the UI no longer renders null as the suggested type. Adds a PARSED section with two queries: one typo (Result<SomeTraiz>) that still produces a concrete suggestion and one fully unknown type (Result<NoSuchTrait>) that leaves proposeCorrectionTo null.
2 parents 237984f + 29639e3 commit 2a391e9

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5050,9 +5050,11 @@ ${obj.displayPath}<span class="${type}">${name}</span>\
50505050
if (query.proposeCorrectionFrom !== null && isTypeSearch) {
50515051
const orig = query.proposeCorrectionFrom;
50525052
const targ = query.proposeCorrectionTo;
5053-
correctionOutput = "<h3 class=\"search-corrections\">" +
5054-
`Type "${orig}" not found and used as generic parameter. ` +
5055-
`Consider searching for "${targ}" instead.</h3>`;
5053+
let message = `Type "${orig}" not found and used as generic parameter.`;
5054+
if (targ !== null) {
5055+
message += ` Consider searching for "${targ}" instead.`;
5056+
}
5057+
correctionOutput = `<h3 class="search-corrections">${message}</h3>`;
50565058
}
50575059
if (firstResult.value) {
50585060
if (correctionOutput !== "") {

tests/rustdoc-js/generics-trait.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,24 @@ const EXPECTED = [
9595
],
9696
},
9797
];
98+
99+
const PARSED = [
100+
{
101+
'query': 'Result<SomeTraiz>',
102+
'userQuery': 'Result<SomeTraiz>',
103+
'foundElems': 1,
104+
'returned': [],
105+
'error': null,
106+
'proposeCorrectionFrom': 'SomeTraiz',
107+
'proposeCorrectionTo': 'SomeTrait',
108+
},
109+
{
110+
'query': 'Result<NoSuchTrait>',
111+
'userQuery': 'Result<NoSuchTrait>',
112+
'foundElems': 1,
113+
'returned': [],
114+
'error': null,
115+
'proposeCorrectionFrom': 'NoSuchTrait',
116+
'proposeCorrectionTo': null,
117+
},
118+
];

0 commit comments

Comments
 (0)