Skip to content

Commit

Permalink
rustdoc: add note about slice/array searches to help popup
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Jun 10, 2023
1 parent 7a1154e commit d3a4cd6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
4 changes: 4 additions & 0 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,10 @@ function preLoadCss(cssUrl) {
<code>-&gt; vec</code> or <code>String, enum:Cow -&gt; bool</code>)",
"You can look for items with an exact name by putting double quotes around \
your request: <code>\"string\"</code>",
"Look for functions that accept or return \
<a href=\"https://doc.rust-lang.org/std/primitive.slice.html\">slices</a> and \
<a href=\"https://doc.rust-lang.org/std/primitive.array.html\">arrays</a> by writing \
square brackets (e.g., <code>-&gt; [u8]</code> or <code>[] -&gt; Option</code>)",
"Look for items inside another one by searching for a path: <code>vec::Vec</code>",
].map(x => "<p>" + x + "</p>").join("");
const div_infos = document.createElement("div");
Expand Down
3 changes: 1 addition & 2 deletions tests/rustdoc-js-std/osstring-to-string.js
Original file line number Diff line number Diff line change
@@ -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' },
]
Expand Down
35 changes: 16 additions & 19 deletions tests/rustdoc-js-std/parser-slice-array.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
const QUERY = [
'[[[D, []]]',
'[[[D, []]]]',
'[] u8',
'[u8]',
'[u8,u8]',
'[u8<u8>]',
'[]',
'[>',
'[<',
'[a>',
'[a<',
'[a',
'[',
']',
'primitive:[u8]',
'macro:[u8]',
];

const PARSED = [
{
query: '[[[D, []]]',
elems: [],
foundElems: 0,
original: '[[[D, []]]',
Expand All @@ -27,6 +9,7 @@ const PARSED = [
error: 'Unclosed `[`',
},
{
query: '[[[D, []]]]',
elems: [
{
name: "[]",
Expand Down Expand Up @@ -79,6 +62,7 @@ const PARSED = [
error: null,
},
{
query: '[] u8',
elems: [
{
name: "[]",
Expand All @@ -104,6 +88,7 @@ const PARSED = [
error: null,
},
{
query: '[u8]',
elems: [
{
name: "[]",
Expand All @@ -130,6 +115,7 @@ const PARSED = [
error: null,
},
{
query: '[u8,u8]',
elems: [
{
name: "[]",
Expand Down Expand Up @@ -164,6 +150,7 @@ const PARSED = [
error: null,
},
{
query: '[u8<u8>]',
elems: [
{
name: "[]",
Expand Down Expand Up @@ -199,6 +186,7 @@ const PARSED = [
error: null,
},
{
query: '[]',
elems: [
{
name: "[]",
Expand All @@ -216,6 +204,7 @@ const PARSED = [
error: null,
},
{
query: '[>',
elems: [],
foundElems: 0,
original: "[>",
Expand All @@ -224,6 +213,7 @@ const PARSED = [
error: "Unexpected `>` after `[`",
},
{
query: '[<',
elems: [],
foundElems: 0,
original: "[<",
Expand All @@ -232,6 +222,7 @@ const PARSED = [
error: "Found generics without a path",
},
{
query: '[a>',
elems: [],
foundElems: 0,
original: "[a>",
Expand All @@ -240,6 +231,7 @@ const PARSED = [
error: "Unexpected `>` after `[`",
},
{
query: '[a<',
elems: [],
foundElems: 0,
original: "[a<",
Expand All @@ -248,6 +240,7 @@ const PARSED = [
error: "Unclosed `<`",
},
{
query: '[a',
elems: [],
foundElems: 0,
original: "[a",
Expand All @@ -256,6 +249,7 @@ const PARSED = [
error: "Unclosed `[`",
},
{
query: '[',
elems: [],
foundElems: 0,
original: "[",
Expand All @@ -264,6 +258,7 @@ const PARSED = [
error: "Unclosed `[`",
},
{
query: ']',
elems: [],
foundElems: 0,
original: "]",
Expand All @@ -272,6 +267,7 @@ const PARSED = [
error: "Unexpected `]`",
},
{
query: 'primitive:[u8]',
elems: [
{
name: "[]",
Expand All @@ -298,6 +294,7 @@ const PARSED = [
error: null,
},
{
query: 'macro:[u8]',
elems: [],
foundElems: 0,
original: "macro:[u8]",
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-js/slice-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const EXPECTED = [
],
},
{
'query': '[TraitDog]',
'query': '[TraitCat]',
'in_args': [
{ 'path': 'slice_array', 'name': 'gamma' },
{ 'path': 'slice_array', 'name': 'epsilon' },
Expand Down

0 comments on commit d3a4cd6

Please sign in to comment.