about summary refs log tree commit diff
path: root/tests/rustdoc-js-std
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-07-02 18:49:29 +0000
committerbors <bors@rust-lang.org>2023-07-02 18:49:29 +0000
commitbf0e22b298e282dec3589f70c67e401588d6c693 (patch)
treee9235bd74701ccb4b34cc30a87dd4c9058824688 /tests/rustdoc-js-std
parent32d81eccd64513bacef9dfa1574543ada6b45d85 (diff)
parente4ee3298656b74dd6be810862b5dd4cb8d2825b8 (diff)
downloadrust-bf0e22b298e282dec3589f70c67e401588d6c693.tar.gz
rust-bf0e22b298e282dec3589f70c67e401588d6c693.zip
Auto merge of #108537 - GuillaumeGomez:rustdoc-search-whitespace-as-separator, r=notriddle
rustdoc: Allow whitespace as path separator like double colon

Fixes https://github.com/rust-lang/rust/issues/108447.

I think it makes sense since it allows more common cases, however it also makes the syntax heavier. Not sure what the rest of the team thinks about it. In any case we'll need to go through FCP.

Full explanation for the changes is available [here](https://github.com/rust-lang/rust/pull/108537#issuecomment-1589480564).

r? `@notriddle`
Diffstat (limited to 'tests/rustdoc-js-std')
-rw-r--r--tests/rustdoc-js-std/parser-errors.js200
-rw-r--r--tests/rustdoc-js-std/parser-filter.js2
-rw-r--r--tests/rustdoc-js-std/parser-generics.js6
-rw-r--r--tests/rustdoc-js-std/parser-quote.js2
-rw-r--r--tests/rustdoc-js-std/parser-separators.js80
-rw-r--r--tests/rustdoc-js-std/parser-slice-array.js6
-rw-r--r--tests/rustdoc-js-std/parser-weird-queries.js40
-rw-r--r--tests/rustdoc-js-std/vec-new.js29
8 files changed, 251 insertions, 114 deletions
diff --git a/tests/rustdoc-js-std/parser-errors.js b/tests/rustdoc-js-std/parser-errors.js
index af7f63f99cb..b32bfea5439 100644
--- a/tests/rustdoc-js-std/parser-errors.js
+++ b/tests/rustdoc-js-std/parser-errors.js
@@ -33,15 +33,24 @@ const PARSED = [
         original: "\"P\" \"P\"",
         returned: [],
         userQuery: "\"p\" \"p\"",
+        error: "Cannot have more than one element if you use quotes",
+    },
+    {
+        query: '"P","P"',
+        elems: [],
+        foundElems: 0,
+        original: "\"P\",\"P\"",
+        returned: [],
+        userQuery: "\"p\",\"p\"",
         error: "Cannot have more than one literal search element",
     },
     {
-        query: 'P "P"',
+        query: "P,\"P\"",
         elems: [],
         foundElems: 0,
-        original: "P \"P\"",
+        original: "P,\"P\"",
         returned: [],
-        userQuery: "p \"p\"",
+        userQuery: "p,\"p\"",
         error: "Cannot use literal search when there is more than one element",
     },
     {
@@ -51,7 +60,16 @@ const PARSED = [
         original: "\"p\" p",
         returned: [],
         userQuery: "\"p\" p",
-        error: "You cannot have more than one element if you use quotes",
+        error: "Cannot have more than one element if you use quotes",
+    },
+    {
+        query: '"p",p',
+        elems: [],
+        foundElems: 0,
+        original: "\"p\",p",
+        returned: [],
+        userQuery: "\"p\",p",
+        error: "Cannot have more than one element if you use quotes",
     },
     {
         query: '"const": p',
@@ -60,7 +78,7 @@ const PARSED = [
         original: "\"const\": p",
         returned: [],
         userQuery: "\"const\": p",
-        error: "You cannot use quotes on type filter",
+        error: "Cannot use quotes on type filter",
     },
     {
         query: "a<:a>",
@@ -108,6 +126,15 @@ const PARSED = [
         error: "Paths cannot start with `::`",
     },
     {
+        query: " ::a::b",
+        elems: [],
+        foundElems: 0,
+        original: "::a::b",
+        returned: [],
+        userQuery: "::a::b",
+        error: "Paths cannot start with `::`",
+    },
+    {
         query: "a::::b",
         elems: [],
         foundElems: 0,
@@ -135,13 +162,13 @@ const PARSED = [
         error: "Expected type filter before `:`",
     },
     {
-        query: "a b:",
+        query: "a,b:",
         elems: [],
         foundElems: 0,
-        original: "a b:",
+        original: "a,b:",
         returned: [],
-        userQuery: "a b:",
-        error: "Unexpected `:` (expected path after type filter)",
+        userQuery: "a,b:",
+        error: "Unexpected `:` (expected path after type filter `b:`)",
     },
     {
         query: "a (b:",
@@ -159,7 +186,7 @@ const PARSED = [
         original: "_:",
         returned: [],
         userQuery: "_:",
-        error: "Unexpected `:` (expected path after type filter)",
+        error: "Unexpected `:` (expected path after type filter `_:`)",
     },
     {
         query: "_:a",
@@ -213,6 +240,15 @@ const PARSED = [
         original: '"p" <a>',
         returned: [],
         userQuery: '"p" <a>',
+        error: "Cannot have more than one element if you use quotes",
+    },
+    {
+        query: '"p",<a>',
+        elems: [],
+        foundElems: 0,
+        original: '"p",<a>',
+        returned: [],
+        userQuery: '"p",<a>',
         error: "Found generics without a path",
     },
     {
@@ -222,7 +258,16 @@ const PARSED = [
         original: '"p" a<a>',
         returned: [],
         userQuery: '"p" a<a>',
-        error: "You cannot have more than one element if you use quotes",
+        error: "Cannot have more than one element if you use quotes",
+    },
+    {
+        query: '"p",a<a>',
+        elems: [],
+        foundElems: 0,
+        original: '"p",a<a>',
+        returned: [],
+        userQuery: '"p",a<a>',
+        error: "Cannot have more than one element if you use quotes",
     },
     {
         query: "a,<",
@@ -240,7 +285,7 @@ const PARSED = [
         original: 'aaaaa<>b',
         returned: [],
         userQuery: 'aaaaa<>b',
-        error: 'Expected `,`, ` `, `:` or `->`, found `b`',
+        error: 'Expected `,`, `:` or `->` after `>`, found `b`',
     },
     {
         query: "fn:aaaaa<>b",
@@ -249,7 +294,7 @@ const PARSED = [
         original: 'fn:aaaaa<>b',
         returned: [],
         userQuery: 'fn:aaaaa<>b',
-        error: 'Expected `,`, ` `, `:` or `->`, found `b`',
+        error: 'Expected `,`, `:` or `->` after `>`, found `b`',
     },
     {
         query: "->a<>b",
@@ -258,7 +303,7 @@ const PARSED = [
         original: '->a<>b',
         returned: [],
         userQuery: '->a<>b',
-        error: 'Expected `,` or ` `, found `b`',
+        error: 'Expected `,` after `>`, found `b`',
     },
     {
         query: "a<->",
@@ -276,7 +321,7 @@ const PARSED = [
         original: 'a:: a',
         returned: [],
         userQuery: 'a:: a',
-        error: 'Paths cannot end with `::`',
+        error: 'Unexpected `:: `',
     },
     {
         query: "a ::a",
@@ -285,7 +330,7 @@ const PARSED = [
         original: 'a ::a',
         returned: [],
         userQuery: 'a ::a',
-        error: 'Paths cannot start with `::`',
+        error: 'Unexpected ` ::`',
     },
     {
         query: "a<a>:",
@@ -294,7 +339,7 @@ const PARSED = [
         original: "a<a>:",
         returned: [],
         userQuery: "a<a>:",
-        error: 'Unexpected `<` in type filter',
+        error: 'Unexpected `<` in type filter (before `:`)',
     },
     {
         query: "a<>:",
@@ -303,7 +348,7 @@ const PARSED = [
         original: "a<>:",
         returned: [],
         userQuery: "a<>:",
-        error: 'Unexpected `<` in type filter',
+        error: 'Unexpected `<` in type filter (before `:`)',
     },
     {
         query: "a,:",
@@ -312,7 +357,7 @@ const PARSED = [
         original: "a,:",
         returned: [],
         userQuery: "a,:",
-        error: 'Unexpected `,` in type filter',
+        error: 'Unexpected `,` in type filter (before `:`)',
     },
     {
         query: "  a<>  :",
@@ -321,7 +366,7 @@ const PARSED = [
         original: "a<>  :",
         returned: [],
         userQuery: "a<>  :",
-        error: 'Unexpected `<` in type filter',
+        error: 'Unexpected `<` in type filter (before `:`)',
     },
     {
         query: "mod : :",
@@ -330,7 +375,16 @@ const PARSED = [
         original: "mod : :",
         returned: [],
         userQuery: "mod : :",
-        error: 'Unexpected `:`',
+        error: 'Unexpected `:` (expected path after type filter `mod:`)',
+    },
+    {
+        query: "mod: :",
+        elems: [],
+        foundElems: 0,
+        original: "mod: :",
+        returned: [],
+        userQuery: "mod: :",
+        error: 'Unexpected `:` (expected path after type filter `mod:`)',
     },
     {
         query: "a!a",
@@ -386,4 +440,108 @@ const PARSED = [
         userQuery: "a<",
         error: "Unclosed `<`",
     },
+    {
+        query: "p<x> , y",
+        elems: [
+            {
+                name: "p",
+                fullPath: ["p"],
+                pathWithoutLast: [],
+                pathLast: "p",
+                generics: [
+                    {
+                        name: "x",
+                        fullPath: ["x"],
+                        pathWithoutLast: [],
+                        pathLast: "x",
+                        generics: [],
+                        typeFilter: -1,
+                    },
+                ],
+                typeFilter: -1,
+            },
+            {
+                name: "y",
+                fullPath: ["y"],
+                pathWithoutLast: [],
+                pathLast: "y",
+                generics: [],
+                typeFilter: -1,
+            },
+        ],
+        foundElems: 2,
+        original: "p<x> , y",
+        returned: [],
+        userQuery: "p<x> , y",
+        error: null,
+    },
+    {
+        query: "p<x , y>",
+        elems: [
+            {
+                name: "p",
+                fullPath: ["p"],
+                pathWithoutLast: [],
+                pathLast: "p",
+                generics: [
+                    {
+                        name: "x",
+                        fullPath: ["x"],
+                        pathWithoutLast: [],
+                        pathLast: "x",
+                        generics: [],
+                        typeFilter: -1,
+                    },
+                    {
+                        name: "y",
+                        fullPath: ["y"],
+                        pathWithoutLast: [],
+                        pathLast: "y",
+                        generics: [],
+                        typeFilter: -1,
+                    },
+                ],
+                typeFilter: -1,
+            },
+        ],
+        foundElems: 1,
+        original: "p<x , y>",
+        returned: [],
+        userQuery: "p<x , y>",
+        error: null,
+    },
+    {
+        query: "p ,x , y",
+        elems: [
+            {
+                name: "p",
+                fullPath: ["p"],
+                pathWithoutLast: [],
+                pathLast: "p",
+                generics: [],
+                typeFilter: -1,
+            },
+            {
+                name: "x",
+                fullPath: ["x"],
+                pathWithoutLast: [],
+                pathLast: "x",
+                generics: [],
+                typeFilter: -1,
+            },
+            {
+                name: "y",
+                fullPath: ["y"],
+                pathWithoutLast: [],
+                pathLast: "y",
+                generics: [],
+                typeFilter: -1,
+            },
+        ],
+        foundElems: 3,
+        original: "p ,x , y",
+        returned: [],
+        userQuery: "p ,x , y",
+        error: null,
+    },
 ];
diff --git a/tests/rustdoc-js-std/parser-filter.js b/tests/rustdoc-js-std/parser-filter.js
index 6f5d66e57ba..3b9cc5b1bf0 100644
--- a/tests/rustdoc-js-std/parser-filter.js
+++ b/tests/rustdoc-js-std/parser-filter.js
@@ -38,7 +38,7 @@ const PARSED = [
         original: "macro<f>:foo",
         returned: [],
         userQuery: "macro<f>:foo",
-        error: "Unexpected `<` in type filter",
+        error: "Unexpected `<` in type filter (before `:`)",
     },
     {
         query: 'macro!',
diff --git a/tests/rustdoc-js-std/parser-generics.js b/tests/rustdoc-js-std/parser-generics.js
index eb3cf455155..726ee56c2c1 100644
--- a/tests/rustdoc-js-std/parser-generics.js
+++ b/tests/rustdoc-js-std/parser-generics.js
@@ -9,7 +9,7 @@ const PARSED = [
         error: 'Unclosed `<`',
     },
     {
-        query: 'p<> u8',
+        query: 'p<>,u8',
         elems: [
             {
                 name: "p",
@@ -29,9 +29,9 @@ const PARSED = [
             },
         ],
         foundElems: 2,
-        original: "p<> u8",
+        original: "p<>,u8",
         returned: [],
-        userQuery: "p<> u8",
+        userQuery: "p<>,u8",
         error: null,
     },
     {
diff --git a/tests/rustdoc-js-std/parser-quote.js b/tests/rustdoc-js-std/parser-quote.js
index 9d2a3620ed7..731673cf463 100644
--- a/tests/rustdoc-js-std/parser-quote.js
+++ b/tests/rustdoc-js-std/parser-quote.js
@@ -38,7 +38,7 @@ const PARSED = [
         original: '"p" -> a',
         returned: [],
         userQuery: '"p" -> a',
-        error: "You cannot have more than one element if you use quotes",
+        error: "Cannot have more than one element if you use quotes",
     },
     {
         query: '"a" -> "p"',
diff --git a/tests/rustdoc-js-std/parser-separators.js b/tests/rustdoc-js-std/parser-separators.js
index 69f9ac29ad3..00c489b51a6 100644
--- a/tests/rustdoc-js-std/parser-separators.js
+++ b/tests/rustdoc-js-std/parser-separators.js
@@ -5,6 +5,24 @@ const PARSED = [
         query: 'aaaaaa	b',
         elems: [
             {
+                name: 'aaaaaa\tb',
+                fullPath: ['aaaaaa', 'b'],
+                pathWithoutLast: ['aaaaaa'],
+                pathLast: 'b',
+                generics: [],
+                typeFilter: -1,
+            },
+        ],
+        foundElems: 1,
+        original: "aaaaaa	b",
+        returned: [],
+        userQuery: "aaaaaa	b",
+        error: null,
+    },
+    {
+        query: "aaaaaa,	b",
+        elems: [
+            {
                 name: 'aaaaaa',
                 fullPath: ['aaaaaa'],
                 pathWithoutLast: [],
@@ -22,32 +40,24 @@ const PARSED = [
             },
         ],
         foundElems: 2,
-        original: "aaaaaa	b",
+        original: "aaaaaa,	b",
         returned: [],
-        userQuery: "aaaaaa	b",
+        userQuery: "aaaaaa,	b",
         error: null,
     },
     {
         query: 'a b',
         elems: [
             {
-                name: 'a',
-                fullPath: ['a'],
-                pathWithoutLast: [],
-                pathLast: 'a',
-                generics: [],
-                typeFilter: -1,
-            },
-            {
-                name: 'b',
-                fullPath: ['b'],
-                pathWithoutLast: [],
+                name: 'a b',
+                fullPath: ['a', 'b'],
+                pathWithoutLast: ['a'],
                 pathLast: 'b',
                 generics: [],
                 typeFilter: -1,
             },
         ],
-        foundElems: 2,
+        foundElems: 1,
         original: "a b",
         returned: [],
         userQuery: "a b",
@@ -83,23 +93,15 @@ const PARSED = [
         query: 'a\tb',
         elems: [
             {
-                name: 'a',
-                fullPath: ['a'],
-                pathWithoutLast: [],
-                pathLast: 'a',
-                generics: [],
-                typeFilter: -1,
-            },
-            {
-                name: 'b',
-                fullPath: ['b'],
-                pathWithoutLast: [],
+                name: 'a\tb',
+                fullPath: ['a', 'b'],
+                pathWithoutLast: ['a'],
                 pathLast: 'b',
                 generics: [],
                 typeFilter: -1,
             },
         ],
-        foundElems: 2,
+        foundElems: 1,
         original: "a\tb",
         returned: [],
         userQuery: "a\tb",
@@ -115,16 +117,9 @@ const PARSED = [
                 pathLast: 'a',
                 generics: [
                     {
-                        name: 'b',
-                        fullPath: ['b'],
-                        pathWithoutLast: [],
-                        pathLast: 'b',
-                        generics: [],
-                    },
-                    {
-                        name: 'c',
-                        fullPath: ['c'],
-                        pathWithoutLast: [],
+                        name: 'b c',
+                        fullPath: ['b', 'c'],
+                        pathWithoutLast: ['b'],
                         pathLast: 'c',
                         generics: [],
                     },
@@ -181,16 +176,9 @@ const PARSED = [
                 pathLast: 'a',
                 generics: [
                     {
-                        name: 'b',
-                        fullPath: ['b'],
-                        pathWithoutLast: [],
-                        pathLast: 'b',
-                        generics: [],
-                    },
-                    {
-                        name: 'c',
-                        fullPath: ['c'],
-                        pathWithoutLast: [],
+                        name: 'b\tc',
+                        fullPath: ['b', 'c'],
+                        pathWithoutLast: ['b'],
                         pathLast: 'c',
                         generics: [],
                     },
diff --git a/tests/rustdoc-js-std/parser-slice-array.js b/tests/rustdoc-js-std/parser-slice-array.js
index f85dd199741..c22b7870dbf 100644
--- a/tests/rustdoc-js-std/parser-slice-array.js
+++ b/tests/rustdoc-js-std/parser-slice-array.js
@@ -62,7 +62,7 @@ const PARSED = [
         error: null,
     },
     {
-        query: '[] u8',
+        query: '[],u8',
         elems: [
             {
                 name: "[]",
@@ -82,9 +82,9 @@ const PARSED = [
             },
         ],
         foundElems: 2,
-        original: "[] u8",
+        original: "[],u8",
         returned: [],
-        userQuery: "[] u8",
+        userQuery: "[],u8",
         error: null,
     },
     {
diff --git a/tests/rustdoc-js-std/parser-weird-queries.js b/tests/rustdoc-js-std/parser-weird-queries.js
index 0e08eaf73c8..720ef66c165 100644
--- a/tests/rustdoc-js-std/parser-weird-queries.js
+++ b/tests/rustdoc-js-std/parser-weird-queries.js
@@ -7,23 +7,14 @@ const PARSED = [
         query: 'a b',
         elems: [
             {
-                name: "a",
-                fullPath: ["a"],
-                pathWithoutLast: [],
-                pathLast: "a",
-                generics: [],
-                typeFilter: -1,
-            },
-            {
-                name: "b",
-                fullPath: ["b"],
-                pathWithoutLast: [],
+                name: "a b",
+                fullPath: ["a", "b"],
+                pathWithoutLast: ["a"],
                 pathLast: "b",
                 generics: [],
-                typeFilter: -1,
             },
         ],
-        foundElems: 2,
+        foundElems: 1,
         original: "a b",
         returned: [],
         userQuery: "a b",
@@ -33,23 +24,14 @@ const PARSED = [
         query: 'a   b',
         elems: [
             {
-                name: "a",
-                fullPath: ["a"],
-                pathWithoutLast: [],
-                pathLast: "a",
-                generics: [],
-                typeFilter: -1,
-            },
-            {
-                name: "b",
-                fullPath: ["b"],
-                pathWithoutLast: [],
+                name: "a   b",
+                fullPath: ["a", "b"],
+                pathWithoutLast: ["a"],
                 pathLast: "b",
                 generics: [],
-                typeFilter: -1,
             },
         ],
-        foundElems: 2,
+        foundElems: 1,
         original: "a   b",
         returned: [],
         userQuery: "a   b",
@@ -73,7 +55,6 @@ const PARSED = [
                 pathWithoutLast: [],
                 pathLast: "aaa",
                 generics: [],
-                typeFilter: -1,
             },
             {
                 name: "a",
@@ -81,7 +62,6 @@ const PARSED = [
                 pathWithoutLast: [],
                 pathLast: "a",
                 generics: [],
-                typeFilter: -1,
             },
         ],
         foundElems: 2,
@@ -106,7 +86,7 @@ const PARSED = [
         original: 'mod    :',
         returned: [],
         userQuery: 'mod    :',
-        error: "Unexpected `:` (expected path after type filter)",
+        error: "Unexpected `:` (expected path after type filter `mod:`)",
     },
     {
         query: 'mod\t:',
@@ -115,6 +95,6 @@ const PARSED = [
         original: 'mod\t:',
         returned: [],
         userQuery: 'mod\t:',
-        error: "Unexpected `:` (expected path after type filter)",
+        error: "Unexpected `:` (expected path after type filter `mod:`)",
     },
 ];
diff --git a/tests/rustdoc-js-std/vec-new.js b/tests/rustdoc-js-std/vec-new.js
index 309f3543faf..9823a417a5d 100644
--- a/tests/rustdoc-js-std/vec-new.js
+++ b/tests/rustdoc-js-std/vec-new.js
@@ -1,9 +1,20 @@
-const EXPECTED = {
-    'query': 'Vec::new',
-    'others': [
-        { 'path': 'std::vec::Vec', 'name': 'new' },
-        { 'path': 'alloc::vec::Vec', 'name': 'new' },
-        { 'path': 'std::vec::Vec', 'name': 'new_in' },
-        { 'path': 'alloc::vec::Vec', 'name': 'new_in' },
-    ],
-};
+const EXPECTED = [
+    {
+        'query': 'Vec::new',
+        'others': [
+            { 'path': 'std::vec::Vec', 'name': 'new' },
+            { 'path': 'alloc::vec::Vec', 'name': 'new' },
+            { 'path': 'std::vec::Vec', 'name': 'new_in' },
+            { 'path': 'alloc::vec::Vec', 'name': 'new_in' },
+        ],
+    },
+    {
+        'query': 'Vec new',
+        'others': [
+            { 'path': 'std::vec::Vec', 'name': 'new' },
+            { 'path': 'alloc::vec::Vec', 'name': 'new' },
+            { 'path': 'std::vec::Vec', 'name': 'new_in' },
+            { 'path': 'alloc::vec::Vec', 'name': 'new_in' },
+        ],
+    },
+];