From d3a4cd68130c8aaed7ce5a4d0a58861b66c72eea Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 6 Jun 2023 17:21:06 -0700 Subject: [PATCH] rustdoc: add note about slice/array searches to help popup --- src/librustdoc/html/static/js/main.js | 4 +++ tests/rustdoc-js-std/osstring-to-string.js | 3 +- tests/rustdoc-js-std/parser-slice-array.js | 35 ++++++++++------------ tests/rustdoc-js/slice-array.js | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 6da51ea0a55..a184b7b705e 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1077,6 +1077,10 @@ function preLoadCss(cssUrl) { -> vec or String, enum:Cow -> bool)", "You can look for items with an exact name by putting double quotes around \ your request: \"string\"", + "Look for functions that accept or return \ + slices and \ + arrays by writing \ + square brackets (e.g., -> [u8] or [] -> Option)", "Look for items inside another one by searching for a path: vec::Vec", ].map(x => "

" + x + "

").join(""); const div_infos = document.createElement("div"); diff --git a/tests/rustdoc-js-std/osstring-to-string.js b/tests/rustdoc-js-std/osstring-to-string.js index 91f517df2ea..17bb602a502 100644 --- a/tests/rustdoc-js-std/osstring-to-string.js +++ b/tests/rustdoc-js-std/osstring-to-string.js @@ -1,9 +1,8 @@ // exact-match // https://github.com/rust-lang/rust/issues/60485#issuecomment-663900624 -const QUERY = 'OsString -> String'; - const EXPECTED = { + 'query': 'OsString -> String', 'others': [ { 'path': 'std::ffi::OsString', 'name': 'into_string' }, ] diff --git a/tests/rustdoc-js-std/parser-slice-array.js b/tests/rustdoc-js-std/parser-slice-array.js index 4c0a1defe71..f85dd199741 100644 --- a/tests/rustdoc-js-std/parser-slice-array.js +++ b/tests/rustdoc-js-std/parser-slice-array.js @@ -1,24 +1,6 @@ -const QUERY = [ - '[[[D, []]]', - '[[[D, []]]]', - '[] u8', - '[u8]', - '[u8,u8]', - '[u8]', - '[]', - '[>', - '[<', - '[a>', - '[a<', - '[a', - '[', - ']', - 'primitive:[u8]', - 'macro:[u8]', -]; - const PARSED = [ { + query: '[[[D, []]]', elems: [], foundElems: 0, original: '[[[D, []]]', @@ -27,6 +9,7 @@ const PARSED = [ error: 'Unclosed `[`', }, { + query: '[[[D, []]]]', elems: [ { name: "[]", @@ -79,6 +62,7 @@ const PARSED = [ error: null, }, { + query: '[] u8', elems: [ { name: "[]", @@ -104,6 +88,7 @@ const PARSED = [ error: null, }, { + query: '[u8]', elems: [ { name: "[]", @@ -130,6 +115,7 @@ const PARSED = [ error: null, }, { + query: '[u8,u8]', elems: [ { name: "[]", @@ -164,6 +150,7 @@ const PARSED = [ error: null, }, { + query: '[u8]', elems: [ { name: "[]", @@ -199,6 +186,7 @@ const PARSED = [ error: null, }, { + query: '[]', elems: [ { name: "[]", @@ -216,6 +204,7 @@ const PARSED = [ error: null, }, { + query: '[>', elems: [], foundElems: 0, original: "[>", @@ -224,6 +213,7 @@ const PARSED = [ error: "Unexpected `>` after `[`", }, { + query: '[<', elems: [], foundElems: 0, original: "[<", @@ -232,6 +222,7 @@ const PARSED = [ error: "Found generics without a path", }, { + query: '[a>', elems: [], foundElems: 0, original: "[a>", @@ -240,6 +231,7 @@ const PARSED = [ error: "Unexpected `>` after `[`", }, { + query: '[a<', elems: [], foundElems: 0, original: "[a<", @@ -248,6 +240,7 @@ const PARSED = [ error: "Unclosed `<`", }, { + query: '[a', elems: [], foundElems: 0, original: "[a", @@ -256,6 +249,7 @@ const PARSED = [ error: "Unclosed `[`", }, { + query: '[', elems: [], foundElems: 0, original: "[", @@ -264,6 +258,7 @@ const PARSED = [ error: "Unclosed `[`", }, { + query: ']', elems: [], foundElems: 0, original: "]", @@ -272,6 +267,7 @@ const PARSED = [ error: "Unexpected `]`", }, { + query: 'primitive:[u8]', elems: [ { name: "[]", @@ -298,6 +294,7 @@ const PARSED = [ error: null, }, { + query: 'macro:[u8]', elems: [], foundElems: 0, original: "macro:[u8]", diff --git a/tests/rustdoc-js/slice-array.js b/tests/rustdoc-js/slice-array.js index 83b9f69d03e..d676d0577c5 100644 --- a/tests/rustdoc-js/slice-array.js +++ b/tests/rustdoc-js/slice-array.js @@ -52,7 +52,7 @@ const EXPECTED = [ ], }, { - 'query': '[TraitDog]', + 'query': '[TraitCat]', 'in_args': [ { 'path': 'slice_array', 'name': 'gamma' }, { 'path': 'slice_array', 'name': 'epsilon' },