Skip to content

Commit 35bddbb

Browse files
committed
rustdoc-search: update tests, fix regex corner case
1 parent c3a08be commit 35bddbb

File tree

6 files changed

+29
-15
lines changed

6 files changed

+29
-15
lines changed

src/librustdoc/html/static/js/search.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,8 @@ function initSearch(rawSearchIndex) {
12681268
} else {
12691269
push(fnType.name, fnType.highlighted);
12701270
if (fnType.generics && fnType.generics.length > 0 &&
1271-
(fnType.generics.some(isTransitivelyHighlighted) || fnType.implDisambiguator !== null)
1271+
(fnType.generics.some(isTransitivelyHighlighted)
1272+
|| type.implDisambiguator !== null)
12721273
) {
12731274
pushNotHighlighted("<");
12741275
formatTypeList(fnType.generics, ", ");
@@ -1713,7 +1714,7 @@ function initSearch(rawSearchIndex) {
17131714
) {
17141715
// [] matches primitive:array or primitive:slice
17151716
// if it matches, then we're fine, and this is an appropriate match candidate
1716-
} else if (fnType.id !== queryElem.id) {
1717+
} else if (fnType.id !== queryElem.id || queryElem.id === null) {
17171718
return false;
17181719
}
17191720
// If the query elem has generics, and the function doesn't,

tests/rustdoc-js-std/parser-ident.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ const PARSED = [
22
{
33
query: "R<!>",
44
elems: [{
5-
name: "r",
5+
name: "R",
6+
normalizedName: "r",
67
fullPath: ["r"],
78
pathWithoutLast: [],
89
pathLast: "r",
@@ -28,6 +29,7 @@ const PARSED = [
2829
query: "!",
2930
elems: [{
3031
name: "never",
32+
normalizedName: "never",
3133
fullPath: ["never"],
3234
pathWithoutLast: [],
3335
pathLast: "never",
@@ -44,6 +46,7 @@ const PARSED = [
4446
query: "a!",
4547
elems: [{
4648
name: "a",
49+
normalizedName: "a",
4750
fullPath: ["a"],
4851
pathWithoutLast: [],
4952
pathLast: "a",
@@ -78,6 +81,7 @@ const PARSED = [
7881
query: "!::b",
7982
elems: [{
8083
name: "!::b",
84+
normalizedName: "!::b",
8185
fullPath: ["never", "b"],
8286
pathWithoutLast: ["never"],
8387
pathLast: "b",
@@ -126,7 +130,8 @@ const PARSED = [
126130
pathLast: "b",
127131
generics: [
128132
{
129-
name: "t",
133+
name: "T",
134+
normalizedName: "t",
130135
fullPath: ["t"],
131136
pathWithoutLast: [],
132137
pathLast: "t",

tests/rustdoc-js-std/parser-literal.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ const PARSED = [
22
{
33
query: 'R<P>',
44
elems: [{
5-
name: "r",
5+
name: "R",
6+
normalizedName: "r",
67
fullPath: ["r"],
78
pathWithoutLast: [],
89
pathLast: "r",
910
generics: [
1011
{
11-
name: "p",
12+
name: "P",
13+
normalizedName: "p",
1214
fullPath: ["p"],
1315
pathWithoutLast: [],
1416
pathLast: "p",

tests/rustdoc-js-std/parser-paths.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ const PARSED = [
22
{
33
query: 'A::B',
44
elems: [{
5-
name: "a::b",
5+
name: "A::B",
6+
normalizedName: "a::b",
67
fullPath: ["a", "b"],
78
pathWithoutLast: ["a"],
89
pathLast: "b",
@@ -19,15 +20,17 @@ const PARSED = [
1920
query: 'A::B,C',
2021
elems: [
2122
{
22-
name: "a::b",
23+
name: "A::B",
24+
normalizedName: "a::b",
2325
fullPath: ["a", "b"],
2426
pathWithoutLast: ["a"],
2527
pathLast: "b",
2628
generics: [],
2729
typeFilter: -1,
2830
},
2931
{
30-
name: "c",
32+
name: "C",
33+
normalizedName: "c",
3134
fullPath: ["c"],
3235
pathWithoutLast: [],
3336
pathLast: "c",
@@ -45,13 +48,15 @@ const PARSED = [
4548
query: 'A::B<f>,C',
4649
elems: [
4750
{
48-
name: "a::b",
51+
name: "A::B",
52+
normalizedName: "a::b",
4953
fullPath: ["a", "b"],
5054
pathWithoutLast: ["a"],
5155
pathLast: "b",
5256
generics: [
5357
{
5458
name: "f",
59+
normalizedName: "f",
5560
fullPath: ["f"],
5661
pathWithoutLast: [],
5762
pathLast: "f",
@@ -61,7 +66,8 @@ const PARSED = [
6166
typeFilter: -1,
6267
},
6368
{
64-
name: "c",
69+
name: "C",
70+
normalizedName: "c",
6571
fullPath: ["c"],
6672
pathWithoutLast: [],
6773
pathLast: "c",

tests/rustdoc-js-std/parser-returned.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ const PARSED = [
55
foundElems: 1,
66
original: "-> F<P>",
77
returned: [{
8-
name: "f",
8+
name: "F",
99
fullPath: ["f"],
1010
pathWithoutLast: [],
1111
pathLast: "f",
1212
generics: [
1313
{
14-
name: "p",
14+
name: "P",
1515
fullPath: ["p"],
1616
pathWithoutLast: [],
1717
pathLast: "p",
@@ -29,7 +29,7 @@ const PARSED = [
2929
foundElems: 1,
3030
original: "-> P",
3131
returned: [{
32-
name: "p",
32+
name: "P",
3333
fullPath: ["p"],
3434
pathWithoutLast: [],
3535
pathLast: "p",

tests/rustdoc-js-std/parser-slice-array.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const PARSED = [
3030
pathLast: "[]",
3131
generics: [
3232
{
33-
name: "d",
33+
name: "D",
3434
fullPath: ["d"],
3535
pathWithoutLast: [],
3636
pathLast: "d",

0 commit comments

Comments
 (0)