From 48bd321a71cb9d9b97da5dda2a01b93ce3b970d7 Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Wed, 26 Nov 2025 06:47:36 +0900 Subject: [PATCH 1/2] fix --- src/librustdoc/html/static/js/search.js | 8 +++++--- tests/rustdoc-js/generics-trait.js | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 2b381d64547b5..1a60d032cf7c0 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.

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

${parts.join(" ")}

`; } 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, + }, +]; From 29639e355244966024165bd700bba0e2d1c44b20 Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Wed, 26 Nov 2025 20:10:37 +0900 Subject: [PATCH 2/2] use string --- src/librustdoc/html/static/js/search.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 1a60d032cf7c0..73bc28e4bc7d0 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -5050,11 +5050,11 @@ ${obj.displayPath}${name}\ if (query.proposeCorrectionFrom !== null && isTypeSearch) { const orig = query.proposeCorrectionFrom; const targ = query.proposeCorrectionTo; - const parts = [`Type "${orig}" not found and used as generic parameter.`]; + let message = `Type "${orig}" not found and used as generic parameter.`; if (targ !== null) { - parts.push(`Consider searching for "${targ}" instead.`); + message += ` Consider searching for "${targ}" instead.`; } - correctionOutput = `

${parts.join(" ")}

`; + correctionOutput = `

${message}

`; } if (firstResult.value) { if (correctionOutput !== "") {