about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2023-04-19 10:16:14 -0700
committerMichael Howell <michael@notriddle.com>2023-04-19 12:56:52 -0700
commitb6f81e04347d9dbd29e59e7dbca3f9289ddb2fe3 (patch)
treeefd9ffd2cc20b89691e52cc305ff84536890ba22
parent4c11822aebd9e9c3bbe798f14fa10ec6db3f3937 (diff)
downloadrust-b6f81e04347d9dbd29e59e7dbca3f9289ddb2fe3.tar.gz
rust-b6f81e04347d9dbd29e59e7dbca3f9289ddb2fe3.zip
rustdoc-search: give longer notification for type corrections
-rw-r--r--src/librustdoc/html/static/js/search.js9
-rw-r--r--tests/rustdoc-gui/search-corrections.goml6
2 files changed, 10 insertions, 5 deletions
diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js
index 2d0a3f0192b..1bee6987739 100644
--- a/src/librustdoc/html/static/js/search.js
+++ b/src/librustdoc/html/static/js/search.js
@@ -1996,8 +1996,13 @@ function initSearch(rawSearchIndex) {
         }
 
         if (results.query.correction !== null) {
-            output += "<h3 class=\"search-corrections\">Showing results for " +
-                `"${results.query.correction}".</h3>`;
+            const orig = results.query.returned.length > 0
+                ? results.query.returned[0].name
+                : results.query.elems[0].name;
+            output += "<h3 class=\"search-corrections\">" +
+                `Type "${orig}" not found. ` +
+                "Showing results for " +
+                `"${results.query.correction}" instead.</h3>`;
         }
 
         const resultsElem = document.createElement("div");
diff --git a/tests/rustdoc-gui/search-corrections.goml b/tests/rustdoc-gui/search-corrections.goml
index 832aa153054..323dd658426 100644
--- a/tests/rustdoc-gui/search-corrections.goml
+++ b/tests/rustdoc-gui/search-corrections.goml
@@ -22,7 +22,7 @@ assert-css: (".search-corrections", {
 })
 assert-text: (
     ".search-corrections",
-    "Showing results for \"notablestructwithlongname\"."
+    "Type \"notablestructwithlongnamr\" not found. Showing results for \"notablestructwithlongname\" instead."
 )
 
 // Corrections do get shown on the "In Return Type" tab.
@@ -33,7 +33,7 @@ assert-css: (".search-corrections", {
 })
 assert-text: (
     ".search-corrections",
-    "Showing results for \"notablestructwithlongname\"."
+    "Type \"notablestructwithlongnamr\" not found. Showing results for \"notablestructwithlongname\" instead."
 )
 
 // Now, explicit return values
@@ -50,5 +50,5 @@ assert-css: (".search-corrections", {
 })
 assert-text: (
     ".search-corrections",
-    "Showing results for \"notablestructwithlongname\"."
+    "Type \"notablestructwithlongnamr\" not found. Showing results for \"notablestructwithlongname\" instead."
 )