Skip to content

Commit

Permalink
rustdoc-search: update tests, fix regex corner case
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Oct 24, 2023
1 parent c3a08be commit 9fda9c9
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,7 @@ function initSearch(rawSearchIndex) {
) {
// [] matches primitive:array or primitive:slice
// if it matches, then we're fine, and this is an appropriate match candidate
} else if (fnType.id !== queryElem.id) {
} else if (fnType.id !== queryElem.id || queryElem.id === null) {
return false;
}
// If the query elem has generics, and the function doesn't,
Expand Down
9 changes: 7 additions & 2 deletions tests/rustdoc-js-std/parser-ident.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const PARSED = [
{
query: "R<!>",
elems: [{
name: "r",
name: "R",
normalizedName: "r",
fullPath: ["r"],
pathWithoutLast: [],
pathLast: "r",
Expand All @@ -28,6 +29,7 @@ const PARSED = [
query: "!",
elems: [{
name: "never",
normalizedName: "never",
fullPath: ["never"],
pathWithoutLast: [],
pathLast: "never",
Expand All @@ -44,6 +46,7 @@ const PARSED = [
query: "a!",
elems: [{
name: "a",
normalizedName: "a",
fullPath: ["a"],
pathWithoutLast: [],
pathLast: "a",
Expand Down Expand Up @@ -78,6 +81,7 @@ const PARSED = [
query: "!::b",
elems: [{
name: "!::b",
normalizedName: "!::b",
fullPath: ["never", "b"],
pathWithoutLast: ["never"],
pathLast: "b",
Expand Down Expand Up @@ -126,7 +130,8 @@ const PARSED = [
pathLast: "b",
generics: [
{
name: "t",
name: "T",
normalizedName: "t",
fullPath: ["t"],
pathWithoutLast: [],
pathLast: "t",
Expand Down
6 changes: 4 additions & 2 deletions tests/rustdoc-js-std/parser-literal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ const PARSED = [
{
query: 'R<P>',
elems: [{
name: "r",
name: "R",
normalizedName: "r",
fullPath: ["r"],
pathWithoutLast: [],
pathLast: "r",
generics: [
{
name: "p",
name: "P",
normalizedName: "p",
fullPath: ["p"],
pathWithoutLast: [],
pathLast: "p",
Expand Down
16 changes: 11 additions & 5 deletions tests/rustdoc-js-std/parser-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const PARSED = [
{
query: 'A::B',
elems: [{
name: "a::b",
name: "A::B",
normalizedName: "a::b",
fullPath: ["a", "b"],
pathWithoutLast: ["a"],
pathLast: "b",
Expand All @@ -19,15 +20,17 @@ const PARSED = [
query: 'A::B,C',
elems: [
{
name: "a::b",
name: "A::B",
normalizedName: "a::b",
fullPath: ["a", "b"],
pathWithoutLast: ["a"],
pathLast: "b",
generics: [],
typeFilter: -1,
},
{
name: "c",
name: "C",
normalizedName: "c",
fullPath: ["c"],
pathWithoutLast: [],
pathLast: "c",
Expand All @@ -45,13 +48,15 @@ const PARSED = [
query: 'A::B<f>,C',
elems: [
{
name: "a::b",
name: "A::B",
normalizedName: "a::b",
fullPath: ["a", "b"],
pathWithoutLast: ["a"],
pathLast: "b",
generics: [
{
name: "f",
normalizedName: "f",
fullPath: ["f"],
pathWithoutLast: [],
pathLast: "f",
Expand All @@ -61,7 +66,8 @@ const PARSED = [
typeFilter: -1,
},
{
name: "c",
name: "C",
normalizedName: "c",
fullPath: ["c"],
pathWithoutLast: [],
pathLast: "c",
Expand Down
6 changes: 3 additions & 3 deletions tests/rustdoc-js-std/parser-returned.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ const PARSED = [
foundElems: 1,
original: "-> F<P>",
returned: [{
name: "f",
name: "F",
fullPath: ["f"],
pathWithoutLast: [],
pathLast: "f",
generics: [
{
name: "p",
name: "P",
fullPath: ["p"],
pathWithoutLast: [],
pathLast: "p",
Expand All @@ -29,7 +29,7 @@ const PARSED = [
foundElems: 1,
original: "-> P",
returned: [{
name: "p",
name: "P",
fullPath: ["p"],
pathWithoutLast: [],
pathLast: "p",
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-js-std/parser-slice-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const PARSED = [
pathLast: "[]",
generics: [
{
name: "d",
name: "D",
fullPath: ["d"],
pathWithoutLast: [],
pathLast: "d",
Expand Down

0 comments on commit 9fda9c9

Please sign in to comment.