diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 2b381d64547b5..73bc28e4bc7d0 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -5050,9 +5050,11 @@ ${obj.displayPath}${name}\ if (query.proposeCorrectionFrom !== null && isTypeSearch) { const orig = query.proposeCorrectionFrom; const targ = query.proposeCorrectionTo; - correctionOutput = "

" + - `Type "${orig}" not found and used as generic parameter. ` + - `Consider searching for "${targ}" instead.

`; + let message = `Type "${orig}" not found and used as generic parameter.`; + if (targ !== null) { + message += ` Consider searching for "${targ}" instead.`; + } + correctionOutput = `

${message}

`; } if (firstResult.value) { if (correctionOutput !== "") { diff --git a/tests/rustdoc-js/generics-trait.js b/tests/rustdoc-js/generics-trait.js index cd100463e9a85..eb8e99e80f99f 100644 --- a/tests/rustdoc-js/generics-trait.js +++ b/tests/rustdoc-js/generics-trait.js @@ -95,3 +95,24 @@ const EXPECTED = [ ], }, ]; + +const PARSED = [ + { + 'query': 'Result', + 'userQuery': 'Result', + 'foundElems': 1, + 'returned': [], + 'error': null, + 'proposeCorrectionFrom': 'SomeTraiz', + 'proposeCorrectionTo': 'SomeTrait', + }, + { + 'query': 'Result', + 'userQuery': 'Result', + 'foundElems': 1, + 'returned': [], + 'error': null, + 'proposeCorrectionFrom': 'NoSuchTrait', + 'proposeCorrectionTo': null, + }, +];