From 5c7e7dfe10acde559ad78a700dfefbfaf0ed8772 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 24 Sep 2024 12:33:09 -0700 Subject: [PATCH] rustdoc-search: pass original names through AST --- src/librustdoc/html/static/js/search.js | 46 +++--- src/tools/rustdoc-js/tester.js | 1 - tests/rustdoc-gui/search-corrections.goml | 12 +- tests/rustdoc-js-std/parser-bindings.js | 52 +++--- tests/rustdoc-js-std/parser-errors.js | 159 +++++++------------ tests/rustdoc-js-std/parser-filter.js | 27 ++-- tests/rustdoc-js-std/parser-generics.js | 18 +-- tests/rustdoc-js-std/parser-hof.js | 86 ++++------ tests/rustdoc-js-std/parser-ident.js | 37 ++--- tests/rustdoc-js-std/parser-literal.js | 7 +- tests/rustdoc-js-std/parser-paths.js | 31 ++-- tests/rustdoc-js-std/parser-quote.js | 21 +-- tests/rustdoc-js-std/parser-reference.js | 55 +++---- tests/rustdoc-js-std/parser-returned.js | 33 ++-- tests/rustdoc-js-std/parser-separators.js | 24 +-- tests/rustdoc-js-std/parser-slice-array.js | 56 +++---- tests/rustdoc-js-std/parser-tuple.js | 65 +++----- tests/rustdoc-js-std/parser-weird-queries.js | 18 +-- tests/rustdoc-js/non-english-identifier.js | 34 ++-- 19 files changed, 295 insertions(+), 487 deletions(-) diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 995c2e04194..a4471f1d885 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -276,7 +276,7 @@ function getFilteredNextElem(query, parserState, elems, isInGenerics) { // The type filter doesn't count as an element since it's a modifier. const typeFilterElem = elems.pop(); checkExtraTypeFilterCharacters(start, parserState); - parserState.typeFilter = typeFilterElem.name; + parserState.typeFilter = typeFilterElem.normalizedPathLast; parserState.pos += 1; parserState.totalElems -= 1; query.literalSearch = false; @@ -686,7 +686,7 @@ function createQueryElement(query, parserState, name, generics, isInGenerics) { } else if (quadcolon !== null) { throw ["Unexpected ", quadcolon[0]]; } - const pathSegments = path.split(/(?:::\s*)|(?:\s+(?:::\s*)?)/); + const pathSegments = path.split(/(?:::\s*)|(?:\s+(?:::\s*)?)/).map(x => x.toLowerCase()); // In case we only have something like `

`, there is no name. if (pathSegments.length === 0 || (pathSegments.length === 1 && pathSegments[0] === "")) { @@ -726,7 +726,10 @@ function createQueryElement(query, parserState, name, generics, isInGenerics) { if (gen.name !== null) { gen.bindingName.generics.unshift(gen); } - bindings.set(gen.bindingName.name, gen.bindingName.generics); + bindings.set( + gen.bindingName.name.toLowerCase().replace(/_/g, ""), + gen.bindingName.generics, + ); return false; } return true; @@ -1786,8 +1789,7 @@ class DocSearch { */ function newParsedQuery(userQuery) { return { - original: userQuery, - userQuery: userQuery.toLowerCase(), + userQuery, elems: [], returned: [], // Total number of "top" elements (does not include generics). @@ -1909,7 +1911,7 @@ class DocSearch { genericsElems: 0, typeFilter: null, isInBinding: null, - userQuery: userQuery.toLowerCase(), + userQuery, }; let query = newParsedQuery(userQuery); @@ -2097,7 +2099,7 @@ class DocSearch { */ const sortResults = async(results, isType, preferredCrate) => { const userQuery = parsedQuery.userQuery; - const casedUserQuery = parsedQuery.original; + const normalizedUserQuery = parsedQuery.userQuery.toLowerCase(); const result_list = []; for (const result of results.values()) { result.item = this.searchIndex[result.id]; @@ -2109,15 +2111,15 @@ class DocSearch { let a, b; // sort by exact case-sensitive match - a = (aaa.item.name !== casedUserQuery); - b = (bbb.item.name !== casedUserQuery); + a = (aaa.item.name !== userQuery); + b = (bbb.item.name !== userQuery); if (a !== b) { return a - b; } // sort by exact match with regard to the last word (mismatch goes later) - a = (aaa.word !== userQuery); - b = (bbb.word !== userQuery); + a = (aaa.word !== normalizedUserQuery); + b = (bbb.word !== normalizedUserQuery); if (a !== b) { return a - b; } @@ -3163,21 +3165,25 @@ class DocSearch { if ((elem.id === null && parsedQuery.totalElems > 1 && elem.typeFilter === -1 && elem.generics.length === 0 && elem.bindings.size === 0) || elem.typeFilter === TY_GENERIC) { - if (genericSymbols.has(elem.name)) { - elem.id = genericSymbols.get(elem.name); + if (genericSymbols.has(elem.normalizedPathLast)) { + elem.id = genericSymbols.get(elem.normalizedPathLast); } else { elem.id = -(genericSymbols.size + 1); - genericSymbols.set(elem.name, elem.id); + genericSymbols.set(elem.normalizedPathLast, elem.id); } - if (elem.typeFilter === -1 && elem.name.length >= 3) { + if (elem.typeFilter === -1 && elem.normalizedPathLast.length >= 3) { // Silly heuristic to catch if the user probably meant // to not write a generic parameter. We don't use it, // just bring it up. - const maxPartDistance = Math.floor(elem.name.length / 3); + const maxPartDistance = Math.floor(elem.normalizedPathLast.length / 3); let matchDist = maxPartDistance + 1; let matchName = ""; for (const name of this.typeNameIdMap.keys()) { - const dist = editDistance(name, elem.name, maxPartDistance); + const dist = editDistance( + name, + elem.normalizedPathLast, + maxPartDistance, + ); if (dist <= matchDist && dist <= maxPartDistance) { if (dist === matchDist && matchName > name) { continue; @@ -3289,7 +3295,7 @@ class DocSearch { sorted_returned, sorted_others, parsedQuery); - await handleAliases(ret, parsedQuery.original.replace(/"/g, ""), + await handleAliases(ret, parsedQuery.userQuery.replace(/"/g, ""), filterCrates, currentCrate); await Promise.all([ret.others, ret.returned, ret.in_args].map(async list => { const descs = await Promise.all(list.map(result => { @@ -3709,11 +3715,11 @@ async function search(forced) { } // Update document title to maintain a meaningful browser history - searchState.title = "\"" + query.original + "\" Search - Rust"; + searchState.title = "\"" + query.userQuery + "\" Search - Rust"; // Because searching is incremental by character, only the most // recent search query is added to the browser history. - updateSearchHistory(buildUrl(query.original, filterCrates)); + updateSearchHistory(buildUrl(query.userQuery, filterCrates)); await showResults( await docSearch.execQuery(query, filterCrates, window.currentCrate), diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js index e162ba033cc..63cda4111e6 100644 --- a/src/tools/rustdoc-js/tester.js +++ b/src/tools/rustdoc-js/tester.js @@ -84,7 +84,6 @@ function checkNeededFields(fullPath, expected, error_text, queryName, position) if (fullPath.length === 0) { fieldsToCheck = [ "foundElems", - "original", "returned", "userQuery", "error", diff --git a/tests/rustdoc-gui/search-corrections.goml b/tests/rustdoc-gui/search-corrections.goml index b81b1f382a9..f80675730c4 100644 --- a/tests/rustdoc-gui/search-corrections.goml +++ b/tests/rustdoc-gui/search-corrections.goml @@ -24,7 +24,7 @@ assert-css: (".search-corrections", { }) assert-text: ( ".search-corrections", - "Type \"notablestructwithlongnamr\" not found. Showing results for closest type name \"notablestructwithlongname\" instead." + "Type \"NotableStructWithLongNamr\" not found. Showing results for closest type name \"notablestructwithlongname\" instead." ) // Corrections do get shown on the "In Return Type" tab. @@ -35,7 +35,7 @@ assert-css: (".search-corrections", { }) assert-text: ( ".search-corrections", - "Type \"notablestructwithlongnamr\" not found. Showing results for closest type name \"notablestructwithlongname\" instead." + "Type \"NotableStructWithLongNamr\" not found. Showing results for closest type name \"notablestructwithlongname\" instead." ) // Now, explicit return values @@ -52,7 +52,7 @@ assert-css: (".search-corrections", { }) assert-text: ( ".search-corrections", - "Type \"notablestructwithlongnamr\" not found. Showing results for closest type name \"notablestructwithlongname\" instead." + "Type \"NotableStructWithLongNamr\" not found. Showing results for closest type name \"notablestructwithlongname\" instead." ) // Now, generic correction @@ -69,7 +69,7 @@ assert-css: (".search-corrections", { }) assert-text: ( ".search-corrections", - "Type \"notablestructwithlongnamr\" not found and used as generic parameter. Consider searching for \"notablestructwithlongname\" instead." + "Type \"NotableStructWithLongNamr\" not found and used as generic parameter. Consider searching for \"notablestructwithlongname\" instead." ) // Now, generic correction plus error @@ -86,7 +86,7 @@ assert-css: (".search-corrections", { }) assert-text: ( ".search-corrections", - "Type \"notablestructwithlongnamr\" not found and used as generic parameter. Consider searching for \"notablestructwithlongname\" instead." + "Type \"NotableStructWithLongNamr\" not found and used as generic parameter. Consider searching for \"notablestructwithlongname\" instead." ) go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" @@ -102,5 +102,5 @@ assert-css: (".error", { }) assert-text: ( ".error", - "Query parser error: \"Generic type parameter notablestructwithlongnamr does not accept generic parameters\"." + "Query parser error: \"Generic type parameter NotableStructWithLongNamr does not accept generic parameters\"." ) diff --git a/tests/rustdoc-js-std/parser-bindings.js b/tests/rustdoc-js-std/parser-bindings.js index c4909c6242d..bd379f139ff 100644 --- a/tests/rustdoc-js-std/parser-bindings.js +++ b/tests/rustdoc-js-std/parser-bindings.js @@ -3,20 +3,22 @@ const PARSED = [ query: 'A', elems: [ { - name: "a", + name: "A", fullPath: ["a"], pathWithoutLast: [], pathLast: "a", + normalizedPathLast: "a", generics: [], bindings: [ [ 'b', [ { - name: "c", + name: "C", fullPath: ["c"], pathWithoutLast: [], pathLast: "c", + normalizedPathLast: "c", generics: [], typeFilter: -1, }, @@ -27,16 +29,15 @@ const PARSED = [ }, ], foundElems: 1, - original: 'A', + userQuery: 'A', returned: [], - userQuery: 'a', error: null, }, { query: 'A', elems: [ { - name: "a", + name: "A", fullPath: ["a"], pathWithoutLast: [], pathLast: "a", @@ -45,7 +46,7 @@ const PARSED = [ [ 'b', [{ - name: "c", + name: "C", fullPath: ["c"], pathWithoutLast: [], pathLast: "c", @@ -58,16 +59,15 @@ const PARSED = [ }, ], foundElems: 1, - original: 'A', + userQuery: 'A', returned: [], - userQuery: 'a', error: null, }, { query: 'A', elems: [ { - name: "a", + name: "A", fullPath: ["a"], pathWithoutLast: [], pathLast: "a", @@ -89,16 +89,15 @@ const PARSED = [ }, ], foundElems: 1, - original: 'A', + userQuery: 'A', returned: [], - userQuery: 'a', error: null, }, { query: 'A', elems: [ { - name: "a", + name: "A", fullPath: ["a"], pathWithoutLast: [], pathLast: "a", @@ -120,16 +119,15 @@ const PARSED = [ }, ], foundElems: 1, - original: 'A', + userQuery: 'A', returned: [], - userQuery: 'a', error: null, }, { query: 'A', elems: [ { - name: "a", + name: "A", fullPath: ["a"], pathWithoutLast: [], pathLast: "a", @@ -160,52 +158,47 @@ const PARSED = [ }, ], foundElems: 1, - original: 'A', + userQuery: 'A', returned: [], - userQuery: 'a', error: null, }, { query: 'A', elems: [], foundElems: 0, - original: 'A', + userQuery: 'A', returned: [], - userQuery: 'a', error: "Cannot write `=` twice in a binding", }, { query: 'A', elems: [], foundElems: 0, - original: 'A', + userQuery: 'A', returned: [], - userQuery: 'a', error: "Unexpected `>` after `=`", }, { query: 'B=C', elems: [], foundElems: 0, - original: 'B=C', + userQuery: 'B=C', returned: [], - userQuery: 'b=c', error: "Type parameter `=` must be within generics list", }, { query: '[B=C]', elems: [], foundElems: 0, - original: '[B=C]', + userQuery: '[B=C]', returned: [], - userQuery: '[b=c]', error: "Type parameter `=` cannot be within slice `[]`", }, { query: 'A=C>', elems: [ { - name: "a", + name: "A", fullPath: ["a"], pathWithoutLast: [], pathLast: "a", @@ -215,7 +208,7 @@ const PARSED = [ 'b', [ { - name: "c", + name: "C", fullPath: ["c"], pathWithoutLast: [], pathLast: "c", @@ -223,7 +216,7 @@ const PARSED = [ typeFilter: -1, }, { - name: "x", + name: "X", fullPath: ["x"], pathWithoutLast: [], pathLast: "x", @@ -237,9 +230,8 @@ const PARSED = [ }, ], foundElems: 1, - original: 'A=C>', + userQuery: 'A=C>', returned: [], - userQuery: 'a=c>', error: null, }, ]; diff --git a/tests/rustdoc-js-std/parser-errors.js b/tests/rustdoc-js-std/parser-errors.js index 5ce35bf511d..068298e7236 100644 --- a/tests/rustdoc-js-std/parser-errors.js +++ b/tests/rustdoc-js-std/parser-errors.js @@ -3,450 +3,400 @@ const PARSED = [ query: '

', elems: [], foundElems: 0, - original: "

", + userQuery: "

", returned: [], - userQuery: "

", error: "Found generics without a path", }, { query: '->

', elems: [], foundElems: 0, - original: "->

", + userQuery: "->

", returned: [], - userQuery: "->

", error: "Found generics without a path", }, { query: '-> *', elems: [], foundElems: 0, - original: "-> *", - returned: [], userQuery: "-> *", + returned: [], error: "Unexpected `*` after ` ` (not a valid identifier)", }, { query: 'a<"P">', elems: [], foundElems: 0, - original: "a<\"P\">", + userQuery: "a<\"P\">", returned: [], - userQuery: "a<\"p\">", error: "Unexpected `\"` in generics", }, { query: '"P" "P"', elems: [], foundElems: 0, - original: "\"P\" \"P\"", + userQuery: "\"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\"", + userQuery: "\"P\",\"P\"", returned: [], - userQuery: "\"p\",\"p\"", error: "Cannot have more than one literal search element", }, { query: "P,\"P\"", elems: [], foundElems: 0, - original: "P,\"P\"", + userQuery: "P,\"P\"", returned: [], - userQuery: "p,\"p\"", error: "Cannot use literal search when there is more than one element", }, { query: '"p" p', elems: [], foundElems: 0, - original: "\"p\" p", - returned: [], userQuery: "\"p\" p", + returned: [], error: "Cannot have more than one element if you use quotes", }, { query: '"p",p', elems: [], foundElems: 0, - original: "\"p\",p", - returned: [], userQuery: "\"p\",p", + returned: [], error: "Cannot have more than one element if you use quotes", }, { query: '"const": p', elems: [], foundElems: 0, - original: "\"const\": p", - returned: [], userQuery: "\"const\": p", + returned: [], error: "Cannot use quotes on type filter", }, { query: "a<:a>", elems: [], foundElems: 0, - original: "a<:a>", - returned: [], userQuery: "a<:a>", + returned: [], error: "Expected type filter before `:`", }, { query: "a<::a>", elems: [], foundElems: 0, - original: "a<::a>", - returned: [], userQuery: "a<::a>", + returned: [], error: "Unexpected `::`: paths cannot start with `::`", }, { query: "(p -> p", elems: [], foundElems: 0, - original: "(p -> p", - returned: [], userQuery: "(p -> p", + returned: [], error: "Unclosed `(`", }, { query: "::a::b", elems: [], foundElems: 0, - original: "::a::b", - returned: [], userQuery: "::a::b", + returned: [], error: "Paths cannot start with `::`", }, { query: " ::a::b", elems: [], foundElems: 0, - original: "::a::b", - returned: [], userQuery: "::a::b", + returned: [], error: "Paths cannot start with `::`", }, { query: "a::::b", elems: [], foundElems: 0, - original: "a::::b", - returned: [], userQuery: "a::::b", + returned: [], error: "Unexpected `::::`", }, { query: "a:: ::b", elems: [], foundElems: 0, - original: "a:: ::b", - returned: [], userQuery: "a:: ::b", + returned: [], error: "Unexpected `:: ::`", }, { query: "a::\t::b", elems: [], foundElems: 0, - original: "a:: ::b", - returned: [], userQuery: "a:: ::b", + returned: [], error: "Unexpected `:: ::`", }, { query: "a::b::", elems: [], foundElems: 0, - original: "a::b::", - returned: [], userQuery: "a::b::", + returned: [], error: "Paths cannot end with `::`", }, { query: ":a", elems: [], foundElems: 0, - original: ":a", - returned: [], userQuery: ":a", + returned: [], error: "Expected type filter before `:`", }, { query: "a,b:", elems: [], foundElems: 0, - original: "a,b:", - returned: [], userQuery: "a,b:", + returned: [], error: "Unexpected `:` (expected path after type filter `b:`)", }, { query: "a (b:", elems: [], foundElems: 0, - original: "a (b:", - returned: [], userQuery: "a (b:", + returned: [], error: "Unclosed `(`", }, { query: "_:", elems: [], foundElems: 0, - original: "_:", - returned: [], userQuery: "_:", + returned: [], error: "Unexpected `_` (not a valid identifier)", }, { query: "ab:", elems: [], foundElems: 0, - original: "ab:", - returned: [], userQuery: "ab:", + returned: [], error: "Unexpected `:` (expected path after type filter `ab:`)", }, { query: "a:b", elems: [], foundElems: 0, - original: "a:b", - returned: [], userQuery: "a:b", + returned: [], error: "Unknown type filter `a`", }, { query: "a-bb", elems: [], foundElems: 0, - original: "a-bb", - returned: [], userQuery: "a-bb", + returned: [], error: "Unexpected `-` (did you mean `->`?)", }, { query: "a>bb", elems: [], foundElems: 0, - original: "a>bb", - returned: [], userQuery: "a>bb", + returned: [], error: "Unexpected `>` (did you mean `->`?)", }, { query: "ab'", elems: [], foundElems: 0, - original: "ab'", - returned: [], userQuery: "ab'", + returned: [], error: "Unexpected `'` after `b` (not a valid identifier)", }, { query: '"p" ', elems: [], foundElems: 0, - original: '"p" ', - returned: [], userQuery: '"p" ', + returned: [], error: "Cannot have more than one element if you use quotes", }, { query: '"p",', elems: [], foundElems: 0, - original: '"p",', - returned: [], userQuery: '"p",', + returned: [], error: "Found generics without a path", }, { query: '"p" a', elems: [], foundElems: 0, - original: '"p" a', - returned: [], userQuery: '"p" a', + returned: [], error: "Cannot have more than one element if you use quotes", }, { query: '"p",a', elems: [], foundElems: 0, - original: '"p",a', - returned: [], userQuery: '"p",a', + returned: [], error: "Cannot have more than one element if you use quotes", }, { query: "a,<", elems: [], foundElems: 0, - original: 'a,<', - returned: [], userQuery: 'a,<', + returned: [], error: 'Found generics without a path', }, { query: "aaaaa<>b", elems: [], foundElems: 0, - original: 'aaaaa<>b', - returned: [], userQuery: 'aaaaa<>b', + returned: [], error: 'Expected `,`, `:` or `->` after `>`, found `b`', }, { query: "fn:aaaaa<>b", elems: [], foundElems: 0, - original: 'fn:aaaaa<>b', - returned: [], userQuery: 'fn:aaaaa<>b', + returned: [], error: 'Expected `,`, `:` or `->` after `>`, found `b`', }, { query: "->a<>b", elems: [], foundElems: 0, - original: '->a<>b', - returned: [], userQuery: '->a<>b', + returned: [], error: 'Expected `,` or `=` after `>`, found `b`', }, { query: "a<->", elems: [], foundElems: 0, - original: 'a<->', - returned: [], userQuery: 'a<->', + returned: [], error: 'Unclosed `<`', }, { query: "a:", elems: [], foundElems: 0, - original: "a:", - returned: [], userQuery: "a:", + returned: [], error: 'Unexpected `<` in type filter (before `:`)', }, { query: "a<>:", elems: [], foundElems: 0, - original: "a<>:", - returned: [], userQuery: "a<>:", + returned: [], error: 'Unexpected `<` in type filter (before `:`)', }, { query: "a,:", elems: [], foundElems: 0, - original: "a,:", - returned: [], userQuery: "a,:", + returned: [], error: 'Expected type filter before `:`', }, { query: "a!:", elems: [], foundElems: 0, - original: "a!:", - returned: [], userQuery: "a!:", + returned: [], error: 'Unexpected `!` in type filter (before `:`)', }, { query: " a<> :", elems: [], foundElems: 0, - original: "a<> :", - returned: [], userQuery: "a<> :", + returned: [], error: 'Expected `,`, `:` or `->` after `>`, found `:`', }, { query: "mod : :", elems: [], foundElems: 0, - original: "mod : :", - returned: [], userQuery: "mod : :", + returned: [], error: 'Unexpected `:` (expected path after type filter `mod:`)', }, { query: "mod: :", elems: [], foundElems: 0, - original: "mod: :", - returned: [], userQuery: "mod: :", + returned: [], error: 'Unexpected `:` (expected path after type filter `mod:`)', }, { query: "a!a", elems: [], foundElems: 0, - original: "a!a", - returned: [], userQuery: "a!a", + returned: [], error: 'Unexpected `!`: it can only be at the end of an ident', }, { query: "a!!", elems: [], foundElems: 0, - original: "a!!", - returned: [], userQuery: "a!!", + returned: [], error: 'Cannot have more than one `!` in an ident', }, { query: "mod:a!", elems: [], foundElems: 0, - original: "mod:a!", - returned: [], userQuery: "mod:a!", + returned: [], error: 'Invalid search type: macro `!` and `mod` both specified', }, { query: "mod:!", elems: [], foundElems: 0, - original: "mod:!", - returned: [], userQuery: "mod:!", + returned: [], error: 'Invalid search type: primitive never type `!` and `mod` both specified', }, { query: "a!::a", elems: [], foundElems: 0, - original: "a!::a", - returned: [], userQuery: "a!::a", + returned: [], error: 'Cannot have associated items in macros', }, { query: "a<", elems: [], foundElems: 0, - original: "a<", - returned: [], userQuery: "a<", + returned: [], error: "Unclosed `<`", }, { @@ -479,9 +429,8 @@ const PARSED = [ }, ], foundElems: 2, - original: "p , y", - returned: [], userQuery: "p , y", + returned: [], error: null, }, { @@ -514,9 +463,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "p", - returned: [], userQuery: "p", + returned: [], error: null, }, { @@ -548,9 +496,8 @@ const PARSED = [ }, ], foundElems: 3, - original: "p ,x , y", - returned: [], userQuery: "p ,x , y", + returned: [], error: null, }, ]; diff --git a/tests/rustdoc-js-std/parser-filter.js b/tests/rustdoc-js-std/parser-filter.js index a1dd0ea3b5a..cda950461f7 100644 --- a/tests/rustdoc-js-std/parser-filter.js +++ b/tests/rustdoc-js-std/parser-filter.js @@ -10,9 +10,8 @@ const PARSED = [ typeFilter: 7, }], foundElems: 1, - original: "fn:foo", - returned: [], userQuery: "fn:foo", + returned: [], error: null, }, { @@ -26,18 +25,16 @@ const PARSED = [ typeFilter: 6, }], foundElems: 1, - original: "enum : foo", - returned: [], userQuery: "enum : foo", + returned: [], error: null, }, { query: 'macro:foo', elems: [], foundElems: 0, - original: "macro:foo", - returned: [], userQuery: "macro:foo", + returned: [], error: "Unexpected `<` in type filter (before `:`)", }, { @@ -51,9 +48,8 @@ const PARSED = [ typeFilter: 16, }], foundElems: 1, - original: "macro!", - returned: [], userQuery: "macro!", + returned: [], error: null, }, { @@ -67,9 +63,8 @@ const PARSED = [ typeFilter: 16, }], foundElems: 1, - original: "macro:mac!", - returned: [], userQuery: "macro:mac!", + returned: [], error: null, }, { @@ -83,16 +78,15 @@ const PARSED = [ typeFilter: 16, }], foundElems: 1, - original: "a::mac!", - returned: [], userQuery: "a::mac!", + returned: [], error: null, }, { query: '-> fn:foo', elems: [], foundElems: 1, - original: "-> fn:foo", + userQuery: "-> fn:foo", returned: [{ name: "foo", fullPath: ["foo"], @@ -101,14 +95,13 @@ const PARSED = [ generics: [], typeFilter: 7, }], - userQuery: "-> fn:foo", error: null, }, { query: '-> fn:foo', elems: [], foundElems: 1, - original: "-> fn:foo", + userQuery: "-> fn:foo", returned: [{ name: "foo", fullPath: ["foo"], @@ -126,14 +119,13 @@ const PARSED = [ ], typeFilter: 7, }], - userQuery: "-> fn:foo", error: null, }, { query: '-> fn:foo', elems: [], foundElems: 1, - original: "-> fn:foo", + userQuery: "-> fn:foo", returned: [{ name: "foo", fullPath: ["foo"], @@ -159,7 +151,6 @@ const PARSED = [ ], typeFilter: 7, }], - userQuery: "-> fn:foo", error: null, }, ]; diff --git a/tests/rustdoc-js-std/parser-generics.js b/tests/rustdoc-js-std/parser-generics.js index 726ee56c2c1..8b8d95bcb88 100644 --- a/tests/rustdoc-js-std/parser-generics.js +++ b/tests/rustdoc-js-std/parser-generics.js @@ -3,9 +3,8 @@ const PARSED = [ query: 'A, E>', elems: [], foundElems: 0, - original: 'A, E>', + userQuery: 'A, E>', returned: [], - userQuery: 'a, e>', error: 'Unclosed `<`', }, { @@ -29,9 +28,8 @@ const PARSED = [ }, ], foundElems: 2, - original: "p<>,u8", - returned: [], userQuery: "p<>,u8", + returned: [], error: null, }, { @@ -55,9 +53,8 @@ const PARSED = [ }, ], foundElems: 1, - original: '"p"', - returned: [], userQuery: '"p"', + returned: [], error: null, }, { @@ -89,9 +86,8 @@ const PARSED = [ }, ], foundElems: 1, - original: 'p>', - returned: [], userQuery: 'p>', + returned: [], error: null, }, { @@ -130,9 +126,8 @@ const PARSED = [ }, ], foundElems: 1, - original: 'p, r>', - returned: [], userQuery: 'p, r>', + returned: [], error: null, }, { @@ -171,9 +166,8 @@ const PARSED = [ }, ], foundElems: 1, - original: 'p>', - returned: [], userQuery: 'p>', + returned: [], error: null, }, ]; diff --git a/tests/rustdoc-js-std/parser-hof.js b/tests/rustdoc-js-std/parser-hof.js index 0b99c45b7a9..ca761015412 100644 --- a/tests/rustdoc-js-std/parser-hof.js +++ b/tests/rustdoc-js-std/parser-hof.js @@ -12,13 +12,13 @@ const PARSED = [ [ "output", [{ - name: "f", + name: "F", fullPath: ["f"], pathWithoutLast: [], pathLast: "f", generics: [ { - name: "p", + name: "P", fullPath: ["p"], pathWithoutLast: [], pathLast: "p", @@ -32,9 +32,8 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "(-> F

)", + userQuery: "(-> F

)", returned: [], - userQuery: "(-> f

)", error: null, }, { @@ -49,7 +48,7 @@ const PARSED = [ [ "output", [{ - name: "p", + name: "P", fullPath: ["p"], pathWithoutLast: [], pathLast: "p", @@ -61,9 +60,8 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "(-> P)", + userQuery: "(-> P)", returned: [], - userQuery: "(-> p)", error: null, }, { @@ -90,9 +88,8 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "(->,a)", - returned: [], userQuery: "(->,a)", + returned: [], error: null, }, { @@ -103,13 +100,13 @@ const PARSED = [ pathWithoutLast: [], pathLast: "->", generics: [{ - name: "f", + name: "F", fullPath: ["f"], pathWithoutLast: [], pathLast: "f", generics: [ { - name: "p", + name: "P", fullPath: ["p"], pathWithoutLast: [], pathLast: "p", @@ -127,9 +124,8 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "(F

->)", + userQuery: "(F

->)", returned: [], - userQuery: "(f

->)", error: null, }, { @@ -140,7 +136,7 @@ const PARSED = [ pathWithoutLast: [], pathLast: "->", generics: [{ - name: "p", + name: "P", fullPath: ["p"], pathWithoutLast: [], pathLast: "p", @@ -156,9 +152,8 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "(P ->)", + userQuery: "(P ->)", returned: [], - userQuery: "(p ->)", error: null, }, { @@ -185,9 +180,8 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "(,a->)", - returned: [], userQuery: "(,a->)", + returned: [], error: null, }, { @@ -221,9 +215,8 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "(aaaaa->a)", - returned: [], userQuery: "(aaaaa->a)", + returned: [], error: null, }, { @@ -267,9 +260,8 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "(aaaaa, b -> a)", - returned: [], userQuery: "(aaaaa, b -> a)", + returned: [], error: null, }, { @@ -313,9 +305,8 @@ const PARSED = [ typeFilter: 1, }], foundElems: 1, - original: "primitive:(aaaaa, b -> a)", - returned: [], userQuery: "primitive:(aaaaa, b -> a)", + returned: [], error: null, }, { @@ -369,16 +360,15 @@ const PARSED = [ } ], foundElems: 2, - original: "x, trait:(aaaaa, b -> a)", - returned: [], userQuery: "x, trait:(aaaaa, b -> a)", + returned: [], error: null, }, // Rust-style HOF { query: "Fn () -> F

", elems: [{ - name: "fn", + name: "Fn", fullPath: ["fn"], pathWithoutLast: [], pathLast: "fn", @@ -387,13 +377,13 @@ const PARSED = [ [ "output", [{ - name: "f", + name: "F", fullPath: ["f"], pathWithoutLast: [], pathLast: "f", generics: [ { - name: "p", + name: "P", fullPath: ["p"], pathWithoutLast: [], pathLast: "p", @@ -407,15 +397,14 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "Fn () -> F

", + userQuery: "Fn () -> F

", returned: [], - userQuery: "fn () -> f

", error: null, }, { query: "FnMut() -> P", elems: [{ - name: "fnmut", + name: "FnMut", fullPath: ["fnmut"], pathWithoutLast: [], pathLast: "fnmut", @@ -424,7 +413,7 @@ const PARSED = [ [ "output", [{ - name: "p", + name: "P", fullPath: ["p"], pathWithoutLast: [], pathLast: "p", @@ -436,15 +425,14 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "FnMut() -> P", + userQuery: "FnMut() -> P", returned: [], - userQuery: "fnmut() -> p", error: null, }, { query: "(FnMut() -> P)", elems: [{ - name: "fnmut", + name: "FnMut", fullPath: ["fnmut"], pathWithoutLast: [], pathLast: "fnmut", @@ -453,7 +441,7 @@ const PARSED = [ [ "output", [{ - name: "p", + name: "P", fullPath: ["p"], pathWithoutLast: [], pathLast: "p", @@ -465,26 +453,25 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "(FnMut() -> P)", + userQuery: "(FnMut() -> P)", returned: [], - userQuery: "(fnmut() -> p)", error: null, }, { query: "Fn(F

)", elems: [{ - name: "fn", + name: "Fn", fullPath: ["fn"], pathWithoutLast: [], pathLast: "fn", generics: [{ - name: "f", + name: "F", fullPath: ["f"], pathWithoutLast: [], pathLast: "f", generics: [ { - name: "p", + name: "P", fullPath: ["p"], pathWithoutLast: [], pathLast: "p", @@ -502,9 +489,8 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "Fn(F

)", + userQuery: "Fn(F

)", returned: [], - userQuery: "fn(f

)", error: null, }, { @@ -548,9 +534,8 @@ const PARSED = [ typeFilter: 1, }], foundElems: 1, - original: "primitive:fnonce(aaaaa, b) -> a", - returned: [], userQuery: "primitive:fnonce(aaaaa, b) -> a", + returned: [], error: null, }, { @@ -594,9 +579,8 @@ const PARSED = [ typeFilter: 1, }], foundElems: 1, - original: "primitive:fnonce(aaaaa, keyword:b) -> trait:a", - returned: [], userQuery: "primitive:fnonce(aaaaa, keyword:b) -> trait:a", + returned: [], error: null, }, { @@ -665,9 +649,8 @@ const PARSED = [ } ], foundElems: 2, - original: "x, trait:fn(aaaaa, b -> a)", - returned: [], userQuery: "x, trait:fn(aaaaa, b -> a)", + returned: [], error: null, }, { @@ -704,9 +687,8 @@ const PARSED = [ } ], foundElems: 2, - original: "a,b(c)", - returned: [], userQuery: "a,b(c)", + returned: [], error: null, }, ]; diff --git a/tests/rustdoc-js-std/parser-ident.js b/tests/rustdoc-js-std/parser-ident.js index cc79c58f1da..f65391b1571 100644 --- a/tests/rustdoc-js-std/parser-ident.js +++ b/tests/rustdoc-js-std/parser-ident.js @@ -2,7 +2,7 @@ const PARSED = [ { query: "R", elems: [{ - name: "r", + name: "R", fullPath: ["r"], pathWithoutLast: [], pathLast: "r", @@ -19,9 +19,8 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "R", + userQuery: "R", returned: [], - userQuery: "r", error: null, }, { @@ -35,9 +34,8 @@ const PARSED = [ typeFilter: 1, }], foundElems: 1, - original: "!", - returned: [], userQuery: "!", + returned: [], error: null, }, { @@ -51,27 +49,24 @@ const PARSED = [ typeFilter: 16, }], foundElems: 1, - original: "a!", - returned: [], userQuery: "a!", + returned: [], error: null, }, { query: "a!::b", elems: [], foundElems: 0, - original: "a!::b", - returned: [], userQuery: "a!::b", + returned: [], error: "Cannot have associated items in macros", }, { query: "!", elems: [], foundElems: 0, - original: "!", + userQuery: "!", returned: [], - userQuery: "!", error: "Never type `!` does not accept generic parameters", }, { @@ -85,36 +80,32 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "!::b", - returned: [], userQuery: "!::b", + returned: [], error: null, }, { query: "b::!", elems: [], foundElems: 0, - original: "b::!", - returned: [], userQuery: "b::!", + returned: [], error: "Never type `!` is not associated item", }, { query: "!::!", elems: [], foundElems: 0, - original: "!::!", - returned: [], userQuery: "!::!", + returned: [], error: "Never type `!` is not associated item", }, { query: "b::!::c", elems: [], foundElems: 0, - original: "b::!::c", - returned: [], userQuery: "b::!::c", + returned: [], error: "Never type `!` is not associated item", }, { @@ -126,7 +117,7 @@ const PARSED = [ pathLast: "b", generics: [ { - name: "t", + name: "T", fullPath: ["t"], pathWithoutLast: [], pathLast: "t", @@ -137,18 +128,16 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "!::b", + userQuery: "!::b", returned: [], - userQuery: "!::b", error: null, }, { query: "a!::b!", elems: [], foundElems: 0, - original: "a!::b!", - returned: [], userQuery: "a!::b!", + returned: [], error: "Cannot have associated items in macros", }, ]; diff --git a/tests/rustdoc-js-std/parser-literal.js b/tests/rustdoc-js-std/parser-literal.js index 87c06224dbf..63e07a246a1 100644 --- a/tests/rustdoc-js-std/parser-literal.js +++ b/tests/rustdoc-js-std/parser-literal.js @@ -2,13 +2,13 @@ const PARSED = [ { query: 'R

', elems: [{ - name: "r", + name: "R", fullPath: ["r"], pathWithoutLast: [], pathLast: "r", generics: [ { - name: "p", + name: "P", fullPath: ["p"], pathWithoutLast: [], pathLast: "p", @@ -18,9 +18,8 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "R

", + userQuery: "R

", returned: [], - userQuery: "r

", error: null, } ]; diff --git a/tests/rustdoc-js-std/parser-paths.js b/tests/rustdoc-js-std/parser-paths.js index 774e5d028cc..bb34e22e518 100644 --- a/tests/rustdoc-js-std/parser-paths.js +++ b/tests/rustdoc-js-std/parser-paths.js @@ -2,7 +2,7 @@ const PARSED = [ { query: 'A::B', elems: [{ - name: "a::b", + name: "A::B", fullPath: ["a", "b"], pathWithoutLast: ["a"], pathLast: "b", @@ -10,9 +10,8 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "A::B", + userQuery: "A::B", returned: [], - userQuery: "a::b", error: null, }, { @@ -26,9 +25,8 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: 'a:: a', - returned: [], userQuery: 'a:: a', + returned: [], error: null, }, { @@ -42,9 +40,8 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: 'a ::a', - returned: [], userQuery: 'a ::a', + returned: [], error: null, }, { @@ -58,16 +55,15 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: 'a :: a', - returned: [], userQuery: 'a :: a', + returned: [], error: null, }, { query: 'A::B,C', elems: [ { - name: "a::b", + name: "A::B", fullPath: ["a", "b"], pathWithoutLast: ["a"], pathLast: "b", @@ -75,7 +71,7 @@ const PARSED = [ typeFilter: -1, }, { - name: "c", + name: "C", fullPath: ["c"], pathWithoutLast: [], pathLast: "c", @@ -84,16 +80,15 @@ const PARSED = [ }, ], foundElems: 2, - original: 'A::B,C', + userQuery: 'A::B,C', returned: [], - userQuery: 'a::b,c', error: null, }, { query: 'A::B,C', elems: [ { - name: "a::b", + name: "A::B", fullPath: ["a", "b"], pathWithoutLast: ["a"], pathLast: "b", @@ -109,7 +104,7 @@ const PARSED = [ typeFilter: -1, }, { - name: "c", + name: "C", fullPath: ["c"], pathWithoutLast: [], pathLast: "c", @@ -118,9 +113,8 @@ const PARSED = [ }, ], foundElems: 2, - original: 'A::B,C', + userQuery: 'A::B,C', returned: [], - userQuery: 'a::b,c', error: null, }, { @@ -134,9 +128,8 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "mod::a", - returned: [], userQuery: "mod::a", + returned: [], error: null, }, ]; diff --git a/tests/rustdoc-js-std/parser-quote.js b/tests/rustdoc-js-std/parser-quote.js index 731673cf463..b485047e385 100644 --- a/tests/rustdoc-js-std/parser-quote.js +++ b/tests/rustdoc-js-std/parser-quote.js @@ -3,7 +3,7 @@ const PARSED = [ query: '-> "p"', elems: [], foundElems: 1, - original: '-> "p"', + userQuery: '-> "p"', returned: [{ name: "p", fullPath: ["p"], @@ -12,7 +12,6 @@ const PARSED = [ generics: [], typeFilter: -1, }], - userQuery: '-> "p"', error: null, }, { @@ -26,54 +25,48 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: '"p",', - returned: [], userQuery: '"p",', + returned: [], error: null, }, { query: '"p" -> a', elems: [], foundElems: 0, - original: '"p" -> a', - returned: [], userQuery: '"p" -> a', + returned: [], error: "Cannot have more than one element if you use quotes", }, { query: '"a" -> "p"', elems: [], foundElems: 0, - original: '"a" -> "p"', - returned: [], userQuery: '"a" -> "p"', + returned: [], error: "Cannot have more than one literal search element", }, { query: '->"-"', elems: [], foundElems: 0, - original: '->"-"', - returned: [], userQuery: '->"-"', + returned: [], error: 'Unexpected `-` in a string element', }, { query: '"a', elems: [], foundElems: 0, - original: '"a', - returned: [], userQuery: '"a', + returned: [], error: 'Unclosed `"`', }, { query: '""', elems: [], foundElems: 0, - original: '""', - returned: [], userQuery: '""', + returned: [], error: 'Cannot have empty string element', }, ]; diff --git a/tests/rustdoc-js-std/parser-reference.js b/tests/rustdoc-js-std/parser-reference.js index 6b1250146be..0fa07ae9895 100644 --- a/tests/rustdoc-js-std/parser-reference.js +++ b/tests/rustdoc-js-std/parser-reference.js @@ -3,18 +3,16 @@ const PARSED = [ query: '&[', elems: [], foundElems: 0, - original: '&[', - returned: [], userQuery: '&[', + returned: [], error: 'Unclosed `[`', }, { query: '[&', elems: [], foundElems: 0, - original: '[&', - returned: [], userQuery: '[&', + returned: [], error: 'Unclosed `[`', }, { @@ -39,7 +37,7 @@ const PARSED = [ pathLast: "reference", generics: [ { - name: "d", + name: "D", fullPath: ["d"], pathWithoutLast: [], pathLast: "d", @@ -65,9 +63,8 @@ const PARSED = [ }, ], foundElems: 2, - original: '&&&D, []', + userQuery: '&&&D, []', returned: [], - userQuery: '&&&d, []', error: null, }, { @@ -98,7 +95,7 @@ const PARSED = [ pathLast: "[]", generics: [ { - name: "d", + name: "D", fullPath: ["d"], pathWithoutLast: [], pathLast: "d", @@ -119,9 +116,8 @@ const PARSED = [ }, ], foundElems: 1, - original: '&&&[D]', + userQuery: '&&&[D]', returned: [], - userQuery: '&&&[d]', error: null, }, { @@ -137,9 +133,8 @@ const PARSED = [ }, ], foundElems: 1, - original: '&', - returned: [], userQuery: '&', + returned: [], error: null, }, { @@ -164,9 +159,8 @@ const PARSED = [ }, ], foundElems: 1, - original: '&mut', - returned: [], userQuery: '&mut', + returned: [], error: null, }, { @@ -190,9 +184,8 @@ const PARSED = [ }, ], foundElems: 2, - original: "&,u8", - returned: [], userQuery: "&,u8", + returned: [], error: null, }, { @@ -225,9 +218,8 @@ const PARSED = [ }, ], foundElems: 2, - original: "&mut,u8", - returned: [], userQuery: "&mut,u8", + returned: [], error: null, }, { @@ -252,9 +244,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "&u8", - returned: [], userQuery: "&u8", + returned: [], error: null, }, { @@ -288,9 +279,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "&u8", - returned: [], userQuery: "&u8", + returned: [], error: null, }, { @@ -324,9 +314,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "u8<&u8>", - returned: [], userQuery: "u8<&u8>", + returned: [], error: null, }, { @@ -368,9 +357,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "u8<&u8, u8>", - returned: [], userQuery: "u8<&u8, u8>", + returned: [], error: null, }, { @@ -404,9 +392,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "u8<&u8>", - returned: [], userQuery: "u8<&u8>", + returned: [], error: null, }, { @@ -456,9 +443,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "u8<&mut u8, u8>", - returned: [], userQuery: "u8<&mut u8, u8>", + returned: [], error: null, }, { @@ -483,18 +469,16 @@ const PARSED = [ }, ], foundElems: 1, - original: "primitive:&u8", - returned: [], userQuery: "primitive:&u8", + returned: [], error: null, }, { query: 'macro:&u8', elems: [], foundElems: 0, - original: "macro:&u8", - returned: [], userQuery: "macro:&u8", + returned: [], error: "Invalid search type: primitive `&` and `macro` both specified", }, { @@ -519,9 +503,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "¯o:u8", - returned: [], userQuery: "¯o:u8", + returned: [], error: null, }, ]; diff --git a/tests/rustdoc-js-std/parser-returned.js b/tests/rustdoc-js-std/parser-returned.js index 8f68209bb96..30ce26a8920 100644 --- a/tests/rustdoc-js-std/parser-returned.js +++ b/tests/rustdoc-js-std/parser-returned.js @@ -3,15 +3,15 @@ const PARSED = [ query: "-> F

", elems: [], foundElems: 1, - original: "-> F

", + userQuery: "-> F

", returned: [{ - name: "f", + name: "F", fullPath: ["f"], pathWithoutLast: [], pathLast: "f", generics: [ { - name: "p", + name: "P", fullPath: ["p"], pathWithoutLast: [], pathLast: "p", @@ -20,30 +20,28 @@ const PARSED = [ ], typeFilter: -1, }], - userQuery: "-> f

", error: null, }, { query: "-> P", elems: [], foundElems: 1, - original: "-> P", + userQuery: "-> P", returned: [{ - name: "p", + name: "P", fullPath: ["p"], pathWithoutLast: [], pathLast: "p", generics: [], typeFilter: -1, }], - userQuery: "-> p", error: null, }, { query: "->,a", elems: [], foundElems: 1, - original: "->,a", + userQuery: "->,a", returned: [{ name: "a", fullPath: ["a"], @@ -52,7 +50,6 @@ const PARSED = [ generics: [], typeFilter: -1, }], - userQuery: "->,a", error: null, }, { @@ -66,7 +63,7 @@ const PARSED = [ typeFilter: -1, }], foundElems: 2, - original: "aaaaa->a", + userQuery: "aaaaa->a", returned: [{ name: "a", fullPath: ["a"], @@ -75,14 +72,13 @@ const PARSED = [ generics: [], typeFilter: -1, }], - userQuery: "aaaaa->a", error: null, }, { query: "-> !", elems: [], foundElems: 1, - original: "-> !", + userQuery: "-> !", returned: [{ name: "never", fullPath: ["never"], @@ -91,7 +87,6 @@ const PARSED = [ generics: [], typeFilter: 1, }], - userQuery: "-> !", error: null, }, { @@ -105,9 +100,8 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "a->", - returned: [], userQuery: "a->", + returned: [], hasReturnArrow: true, error: null, }, @@ -122,9 +116,8 @@ const PARSED = [ typeFilter: 1, }], foundElems: 1, - original: "!->", - returned: [], userQuery: "!->", + returned: [], hasReturnArrow: true, error: null, }, @@ -139,9 +132,8 @@ const PARSED = [ typeFilter: 1, }], foundElems: 1, - original: "! ->", - returned: [], userQuery: "! ->", + returned: [], hasReturnArrow: true, error: null, }, @@ -156,9 +148,8 @@ const PARSED = [ typeFilter: 1, }], foundElems: 1, - original: "primitive:!->", - returned: [], userQuery: "primitive:!->", + returned: [], hasReturnArrow: true, error: null, }, diff --git a/tests/rustdoc-js-std/parser-separators.js b/tests/rustdoc-js-std/parser-separators.js index 7f95f61b006..cf271c80cdc 100644 --- a/tests/rustdoc-js-std/parser-separators.js +++ b/tests/rustdoc-js-std/parser-separators.js @@ -14,9 +14,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "aaaaaa b", - returned: [], userQuery: "aaaaaa b", + returned: [], error: null, }, { @@ -40,9 +39,8 @@ const PARSED = [ }, ], foundElems: 2, - original: "aaaaaa, b", - returned: [], userQuery: "aaaaaa, b", + returned: [], error: null, }, { @@ -58,9 +56,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "a b", - returned: [], userQuery: "a b", + returned: [], error: null, }, { @@ -84,9 +81,8 @@ const PARSED = [ }, ], foundElems: 2, - original: "a,b", - returned: [], userQuery: "a,b", + returned: [], error: null, }, { @@ -102,9 +98,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "a b", - returned: [], userQuery: "a b", + returned: [], error: null, }, { @@ -128,9 +123,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "a", - returned: [], userQuery: "a", + returned: [], error: null, }, { @@ -161,9 +155,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "a", - returned: [], userQuery: "a", + returned: [], error: null, }, { @@ -187,9 +180,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "a", - returned: [], userQuery: "a", + returned: [], error: null, }, ]; diff --git a/tests/rustdoc-js-std/parser-slice-array.js b/tests/rustdoc-js-std/parser-slice-array.js index 1de52af94e6..65797945535 100644 --- a/tests/rustdoc-js-std/parser-slice-array.js +++ b/tests/rustdoc-js-std/parser-slice-array.js @@ -3,9 +3,8 @@ const PARSED = [ query: '[[[D, []]]', elems: [], foundElems: 0, - original: '[[[D, []]]', + userQuery: '[[[D, []]]', returned: [], - userQuery: '[[[d, []]]', error: 'Unclosed `[`', }, { @@ -30,7 +29,7 @@ const PARSED = [ pathLast: "[]", generics: [ { - name: "d", + name: "D", fullPath: ["d"], pathWithoutLast: [], pathLast: "d", @@ -56,9 +55,8 @@ const PARSED = [ }, ], foundElems: 1, - original: '[[[D, []]]]', + userQuery: '[[[D, []]]]', returned: [], - userQuery: '[[[d, []]]]', error: null, }, { @@ -82,9 +80,8 @@ const PARSED = [ }, ], foundElems: 2, - original: "[],u8", - returned: [], userQuery: "[],u8", + returned: [], error: null, }, { @@ -109,9 +106,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "[u8]", - returned: [], userQuery: "[u8]", + returned: [], error: null, }, { @@ -144,9 +140,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "[u8,u8]", - returned: [], userQuery: "[u8,u8]", + returned: [], error: null, }, { @@ -180,9 +175,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "[u8]", - returned: [], userQuery: "[u8]", + returned: [], error: null, }, { @@ -198,90 +192,80 @@ const PARSED = [ }, ], foundElems: 1, - original: "[]", - returned: [], userQuery: "[]", + returned: [], error: null, }, { query: '[>', elems: [], foundElems: 0, - original: "[>", - returned: [], userQuery: "[>", + returned: [], error: "Unexpected `>` after `[`", }, { query: '[<', elems: [], foundElems: 0, - original: "[<", - returned: [], userQuery: "[<", + returned: [], error: "Found generics without a path", }, { query: '[a>', elems: [], foundElems: 0, - original: "[a>", - returned: [], userQuery: "[a>", + returned: [], error: "Unexpected `>` after `[`", }, { query: '[a<', elems: [], foundElems: 0, - original: "[a<", - returned: [], userQuery: "[a<", + returned: [], error: "Unclosed `<`", }, { query: '[a', elems: [], foundElems: 0, - original: "[a", - returned: [], userQuery: "[a", + returned: [], error: "Unclosed `[`", }, { query: '[', elems: [], foundElems: 0, - original: "[", - returned: [], userQuery: "[", + returned: [], error: "Unclosed `[`", }, { query: ']', elems: [], foundElems: 0, - original: "]", - returned: [], userQuery: "]", + returned: [], error: "Unexpected `]`", }, { query: '[a', elems: [], foundElems: 0, - original: "[a", - returned: [], userQuery: "[a", + returned: [], error: "Unclosed `[`", }, { query: 'a]', elems: [], foundElems: 0, - original: "a]", - returned: [], userQuery: "a]", + returned: [], error: "Unexpected `]` after `>`", }, { @@ -306,18 +290,16 @@ const PARSED = [ }, ], foundElems: 1, - original: "primitive:[u8]", - returned: [], userQuery: "primitive:[u8]", + returned: [], error: null, }, { query: 'macro:[u8]', elems: [], foundElems: 0, - original: "macro:[u8]", - returned: [], userQuery: "macro:[u8]", + returned: [], error: "Invalid search type: primitive `[]` and `macro` both specified", }, ]; diff --git a/tests/rustdoc-js-std/parser-tuple.js b/tests/rustdoc-js-std/parser-tuple.js index eb16289d3c0..61925068387 100644 --- a/tests/rustdoc-js-std/parser-tuple.js +++ b/tests/rustdoc-js-std/parser-tuple.js @@ -3,9 +3,8 @@ const PARSED = [ query: '(((D, ()))', elems: [], foundElems: 0, - original: '(((D, ()))', + userQuery: '(((D, ()))', returned: [], - userQuery: '(((d, ()))', error: 'Unclosed `(`', }, { @@ -18,7 +17,7 @@ const PARSED = [ pathLast: "()", generics: [ { - name: "d", + name: "D", fullPath: ["d"], pathWithoutLast: [], pathLast: "d", @@ -38,9 +37,8 @@ const PARSED = [ } ], foundElems: 1, - original: '(((D, ())))', + userQuery: '(((D, ())))', returned: [], - userQuery: '(((d, ())))', error: null, }, { @@ -64,9 +62,8 @@ const PARSED = [ }, ], foundElems: 2, - original: "(),u8", - returned: [], userQuery: "(),u8", + returned: [], error: null, }, // Parens act as grouping operators when: @@ -88,9 +85,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "(u8)", - returned: [], userQuery: "(u8)", + returned: [], error: null, }, { @@ -115,9 +111,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "(u8,)", - returned: [], userQuery: "(u8,)", + returned: [], error: null, }, { @@ -142,9 +137,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "(,u8)", - returned: [], userQuery: "(,u8)", + returned: [], error: null, }, { @@ -169,9 +163,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "primitive:(u8)", - returned: [], userQuery: "primitive:(u8)", + returned: [], error: null, }, { @@ -187,9 +180,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "(primitive:u8)", - returned: [], userQuery: "(primitive:u8)", + returned: [], error: null, }, { @@ -222,9 +214,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "(u8,u8)", - returned: [], userQuery: "(u8,u8)", + returned: [], error: null, }, { @@ -249,9 +240,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "(u8)", - returned: [], userQuery: "(u8)", + returned: [], error: null, }, { @@ -267,99 +257,88 @@ const PARSED = [ }, ], foundElems: 1, - original: "()", - returned: [], userQuery: "()", + returned: [], error: null, }, { query: '(>', elems: [], foundElems: 0, - original: "(>", - returned: [], userQuery: "(>", + returned: [], error: "Unexpected `>` after `(`", }, { query: '(<', elems: [], foundElems: 0, - original: "(<", - returned: [], userQuery: "(<", + returned: [], error: "Found generics without a path", }, { query: '(a>', elems: [], foundElems: 0, - original: "(a>", - returned: [], userQuery: "(a>", + returned: [], error: "Unexpected `>` after `(`", }, { query: '(a<', elems: [], foundElems: 0, - original: "(a<", - returned: [], userQuery: "(a<", + returned: [], error: "Unclosed `<`", }, { query: '(a', elems: [], foundElems: 0, - original: "(a", - returned: [], userQuery: "(a", + returned: [], error: "Unclosed `(`", }, { query: '(', elems: [], foundElems: 0, - original: "(", - returned: [], userQuery: "(", + returned: [], error: "Unclosed `(`", }, { query: ')', elems: [], foundElems: 0, - original: ")", - returned: [], userQuery: ")", + returned: [], error: "Unexpected `)`", }, { query: '(a', elems: [], foundElems: 0, - original: "(a", - returned: [], userQuery: "(a", + returned: [], error: "Unclosed `(`", }, { query: 'a)', elems: [], foundElems: 0, - original: "a)", - returned: [], userQuery: "a)", + returned: [], error: "Unexpected `)` after `>`", }, { query: 'macro:(u8)', elems: [], foundElems: 0, - original: "macro:(u8)", - returned: [], userQuery: "macro:(u8)", + returned: [], error: "Invalid search type: primitive `()` and `macro` both specified", }, ]; diff --git a/tests/rustdoc-js-std/parser-weird-queries.js b/tests/rustdoc-js-std/parser-weird-queries.js index 499b82a3469..828b0a7d9f6 100644 --- a/tests/rustdoc-js-std/parser-weird-queries.js +++ b/tests/rustdoc-js-std/parser-weird-queries.js @@ -15,9 +15,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "a b", - returned: [], userQuery: "a b", + returned: [], error: null, }, { @@ -32,9 +31,8 @@ const PARSED = [ }, ], foundElems: 1, - original: "a b", - returned: [], userQuery: "a b", + returned: [], error: null, }, { @@ -56,36 +54,32 @@ const PARSED = [ }, ], foundElems: 2, - original: "aaa,a", - returned: [], userQuery: "aaa,a", + returned: [], error: null, }, { query: ',,,,', elems: [], foundElems: 0, - original: ",,,,", - returned: [], userQuery: ",,,,", + returned: [], error: null, }, { query: 'mod :', elems: [], foundElems: 0, - original: 'mod :', - returned: [], userQuery: 'mod :', + returned: [], error: "Unexpected `:` (expected path after type filter `mod:`)", }, { query: 'mod\t:', elems: [], foundElems: 0, - original: 'mod :', - returned: [], userQuery: 'mod :', + returned: [], error: "Unexpected `:` (expected path after type filter `mod:`)", }, ]; diff --git a/tests/rustdoc-js/non-english-identifier.js b/tests/rustdoc-js/non-english-identifier.js index 1765a69152a..6a2c4cc637c 100644 --- a/tests/rustdoc-js/non-english-identifier.js +++ b/tests/rustdoc-js/non-english-identifier.js @@ -11,30 +11,29 @@ const PARSED = [ }], returned: [], foundElems: 1, - original: "中文", userQuery: "中文", error: null, }, { query: '_0Mixed中英文', elems: [{ - name: "_0mixed中英文", + name: "_0Mixed中英文", fullPath: ["_0mixed中英文"], pathWithoutLast: [], pathLast: "_0mixed中英文", + normalizedPathLast: "0mixed中英文", generics: [], typeFilter: -1, }], foundElems: 1, - original: "_0Mixed中英文", + userQuery: "_0Mixed中英文", returned: [], - userQuery: "_0mixed中英文", error: null, }, { query: 'my_crate::中文API', elems: [{ - name: "my_crate::中文api", + name: "my_crate::中文API", fullPath: ["my_crate", "中文api"], pathWithoutLast: ["my_crate"], pathLast: "中文api", @@ -42,26 +41,25 @@ const PARSED = [ typeFilter: -1, }], foundElems: 1, - original: "my_crate::中文API", + userQuery: "my_crate::中文API", returned: [], - userQuery: "my_crate::中文api", error: null, }, { query: '类型A,类型B<约束C>->返回类型<关联类型=路径::约束D>', elems: [{ - name: "类型a", + name: "类型A", fullPath: ["类型a"], pathWithoutLast: [], pathLast: "类型a", generics: [], }, { - name: "类型b", + name: "类型B", fullPath: ["类型b"], pathWithoutLast: [], pathLast: "类型b", generics: [{ - name: "约束c", + name: "约束C", fullPath: ["约束c"], pathWithoutLast: [], pathLast: "约束c", @@ -71,15 +69,21 @@ const PARSED = [ foundElems: 3, totalElems: 5, literalSearch: true, - original: "类型A,类型B<约束C>->返回类型<关联类型=路径::约束D>", + userQuery: "类型A,类型B<约束C>->返回类型<关联类型=路径::约束D>", returned: [{ name: "返回类型", fullPath: ["返回类型"], pathWithoutLast: [], pathLast: "返回类型", generics: [], + bindings: [["关联类型", [{ + name: "路径::约束D", + fullPath: ["路径", "约束d"], + pathWithoutLast: ["路径"], + pathLast: "约束d", + generics: [], + }]]], }], - userQuery: "类型a,类型b<约束c>->返回类型<关联类型=路径::约束d>", error: null, }, { @@ -93,18 +97,16 @@ const PARSED = [ typeFilter: 16, }], foundElems: 1, - original: "my_crate 中文宏!", - returned: [], userQuery: "my_crate 中文宏!", + returned: [], error: null, }, { query: '非法符号——', elems: [], foundElems: 0, - original: "非法符号——", - returned: [], userQuery: "非法符号——", + returned: [], error: "Unexpected `—` after `号` (not a valid identifier)", } ]