}
+ * @param {Array<{name: string, ty: number}>} paths
*
* @return {null|FunctionSearchType}
*/
- function buildFunctionSearchType(functionSearchType, lowercasePaths) {
+ function buildFunctionSearchType(functionSearchType, lowercasePaths, paths) {
const INPUTS_DATA = 0;
const OUTPUT_DATA = 1;
// `0` is used as a sentinel because it's fewer bytes than `null`
@@ -2648,20 +2954,26 @@ ${item.displayPath}${name}\
}
let inputs, output;
if (typeof functionSearchType[INPUTS_DATA] === "number") {
- inputs = [buildItemSearchType(functionSearchType[INPUTS_DATA], lowercasePaths)];
+ inputs = [buildItemSearchType(functionSearchType[INPUTS_DATA], lowercasePaths, paths)];
} else {
inputs = buildItemSearchTypeAll(
functionSearchType[INPUTS_DATA],
- lowercasePaths
+ lowercasePaths,
+ paths
);
}
if (functionSearchType.length > 1) {
if (typeof functionSearchType[OUTPUT_DATA] === "number") {
- output = [buildItemSearchType(functionSearchType[OUTPUT_DATA], lowercasePaths)];
+ output = [buildItemSearchType(
+ functionSearchType[OUTPUT_DATA],
+ lowercasePaths,
+ paths
+ )];
} else {
output = buildItemSearchTypeAll(
functionSearchType[OUTPUT_DATA],
- lowercasePaths
+ lowercasePaths,
+ paths
);
}
} else {
@@ -2671,8 +2983,8 @@ ${item.displayPath}${name}\
const l = functionSearchType.length;
for (let i = 2; i < l; ++i) {
where_clause.push(typeof functionSearchType[i] === "number"
- ? [buildItemSearchType(functionSearchType[i], lowercasePaths)]
- : buildItemSearchTypeAll(functionSearchType[i], lowercasePaths));
+ ? [buildItemSearchType(functionSearchType[i], lowercasePaths, paths)]
+ : buildItemSearchTypeAll(functionSearchType[i], lowercasePaths, paths));
}
return {
inputs, output, where_clause,
@@ -2697,6 +3009,8 @@ ${item.displayPath}${name}\
typeNameIdOfArray = buildTypeMapIndex("array");
typeNameIdOfSlice = buildTypeMapIndex("slice");
typeNameIdOfArrayOrSlice = buildTypeMapIndex("[]");
+ typeNameIdOfNever = buildTypeMapIndex("never");
+ typeNameIdOfTuple = buildTypeMapIndex("tuple");
for (const crate in rawSearchIndex) {
if (!hasOwnPropertyRustdoc(rawSearchIndex, crate)) {
@@ -2856,7 +3170,8 @@ ${item.displayPath}${name}\
parent: itemParentIdxs[i] > 0 ? paths[itemParentIdxs[i] - 1] : undefined,
type: buildFunctionSearchType(
itemFunctionSearchTypes[i],
- lowercasePaths
+ lowercasePaths,
+ paths
),
id: id,
normalizedName: word.indexOf("_") === -1 ? word : word.replace(/_/g, ""),
diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js
index c7e6dd3615e94..9d979067d6a63 100644
--- a/src/tools/rustdoc-js/tester.js
+++ b/src/tools/rustdoc-js/tester.js
@@ -373,8 +373,35 @@ function loadSearchJS(doc_folder, resource_suffix) {
return {
doSearch: function(queryStr, filterCrate, currentCrate) {
- return searchModule.execQuery(searchModule.parseQuery(queryStr), searchWords,
+ const results = searchModule.execQuery(searchModule.parseQuery(queryStr), searchWords,
filterCrate, currentCrate);
+ for (const key in results) {
+ if (results[key]) {
+ for (const resultKey in results[key]) {
+ if (!Object.prototype.hasOwnProperty.call(results[key], resultKey)) {
+ continue;
+ }
+ const entry = results[key][resultKey];
+ if (!entry) {
+ continue;
+ }
+ if (Object.prototype.hasOwnProperty.call(entry, "displayTypeSignature") &&
+ entry.displayTypeSignature !== null &&
+ entry.displayTypeSignature instanceof Array
+ ) {
+ entry.displayTypeSignature.forEach((value, index) => {
+ if (index % 2 === 1) {
+ entry.displayTypeSignature[index] = "*" + value + "*";
+ } else {
+ entry.displayTypeSignature[index] = value;
+ }
+ });
+ entry.displayTypeSignature = entry.displayTypeSignature.join("");
+ }
+ }
+ }
+ }
+ return results;
},
getCorrections: function(queryStr, filterCrate, currentCrate) {
const parsedQuery = searchModule.parseQuery(queryStr);
diff --git a/tests/rustdoc-gui/search-corrections.goml b/tests/rustdoc-gui/search-corrections.goml
index aeb3c9b31a3fd..a8a3f3eda0e97 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-ident.js b/tests/rustdoc-js-std/parser-ident.js
index f65a7ce6692b0..c8f4cd5d32005 100644
--- a/tests/rustdoc-js-std/parser-ident.js
+++ b/tests/rustdoc-js-std/parser-ident.js
@@ -2,7 +2,8 @@ const PARSED = [
{
query: "R",
elems: [{
- name: "r",
+ name: "R",
+ normalizedName: "r",
fullPath: ["r"],
pathWithoutLast: [],
pathLast: "r",
@@ -28,6 +29,7 @@ const PARSED = [
query: "!",
elems: [{
name: "never",
+ normalizedName: "never",
fullPath: ["never"],
pathWithoutLast: [],
pathLast: "never",
@@ -44,6 +46,7 @@ const PARSED = [
query: "a!",
elems: [{
name: "a",
+ normalizedName: "a",
fullPath: ["a"],
pathWithoutLast: [],
pathLast: "a",
@@ -78,6 +81,7 @@ const PARSED = [
query: "!::b",
elems: [{
name: "!::b",
+ normalizedName: "!::b",
fullPath: ["never", "b"],
pathWithoutLast: ["never"],
pathLast: "b",
@@ -126,7 +130,8 @@ const PARSED = [
pathLast: "b",
generics: [
{
- name: "t",
+ name: "T",
+ normalizedName: "t",
fullPath: ["t"],
pathWithoutLast: [],
pathLast: "t",
diff --git a/tests/rustdoc-js-std/parser-literal.js b/tests/rustdoc-js-std/parser-literal.js
index 87c06224dbf2d..4ff8038f5a3e2 100644
--- a/tests/rustdoc-js-std/parser-literal.js
+++ b/tests/rustdoc-js-std/parser-literal.js
@@ -2,13 +2,15 @@ const PARSED = [
{
query: 'R',
elems: [{
- name: "r",
+ name: "R",
+ normalizedName: "r",
fullPath: ["r"],
pathWithoutLast: [],
pathLast: "r",
generics: [
{
- name: "p",
+ name: "P",
+ normalizedName: "p",
fullPath: ["p"],
pathWithoutLast: [],
pathLast: "p",
diff --git a/tests/rustdoc-js-std/parser-paths.js b/tests/rustdoc-js-std/parser-paths.js
index 8d4dedf3f46c8..8524057057a86 100644
--- a/tests/rustdoc-js-std/parser-paths.js
+++ b/tests/rustdoc-js-std/parser-paths.js
@@ -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",
@@ -19,7 +20,8 @@ const PARSED = [
query: 'A::B,C',
elems: [
{
- name: "a::b",
+ name: "A::B",
+ normalizedName: "a::b",
fullPath: ["a", "b"],
pathWithoutLast: ["a"],
pathLast: "b",
@@ -27,7 +29,8 @@ const PARSED = [
typeFilter: -1,
},
{
- name: "c",
+ name: "C",
+ normalizedName: "c",
fullPath: ["c"],
pathWithoutLast: [],
pathLast: "c",
@@ -45,13 +48,15 @@ const PARSED = [
query: 'A::B,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",
@@ -61,7 +66,8 @@ const PARSED = [
typeFilter: -1,
},
{
- name: "c",
+ name: "C",
+ normalizedName: "c",
fullPath: ["c"],
pathWithoutLast: [],
pathLast: "c",
diff --git a/tests/rustdoc-js-std/parser-returned.js b/tests/rustdoc-js-std/parser-returned.js
index 6ea86609115bf..be6340e9e5247 100644
--- a/tests/rustdoc-js-std/parser-returned.js
+++ b/tests/rustdoc-js-std/parser-returned.js
@@ -5,13 +5,13 @@ const PARSED = [
foundElems: 1,
original: "-> F",
returned: [{
- name: "f",
+ name: "F",
fullPath: ["f"],
pathWithoutLast: [],
pathLast: "f",
generics: [
{
- name: "p",
+ name: "P",
fullPath: ["p"],
pathWithoutLast: [],
pathLast: "p",
@@ -29,7 +29,7 @@ const PARSED = [
foundElems: 1,
original: "-> P",
returned: [{
- name: "p",
+ name: "P",
fullPath: ["p"],
pathWithoutLast: [],
pathLast: "p",
diff --git a/tests/rustdoc-js-std/parser-slice-array.js b/tests/rustdoc-js-std/parser-slice-array.js
index c22b7870dbf88..4ffee261cd448 100644
--- a/tests/rustdoc-js-std/parser-slice-array.js
+++ b/tests/rustdoc-js-std/parser-slice-array.js
@@ -30,7 +30,7 @@ const PARSED = [
pathLast: "[]",
generics: [
{
- name: "d",
+ name: "D",
fullPath: ["d"],
pathWithoutLast: [],
pathLast: "d",
diff --git a/tests/rustdoc-js/generics-impl.js b/tests/rustdoc-js/generics-impl.js
index 5e33e224876fe..1e9d57dcf6e85 100644
--- a/tests/rustdoc-js/generics-impl.js
+++ b/tests/rustdoc-js/generics-impl.js
@@ -4,33 +4,61 @@ const EXPECTED = [
{
'query': 'Aaaaaaa -> u32',
'others': [
- { 'path': 'generics_impl::Aaaaaaa', 'name': 'bbbbbbb' },
+ {
+ 'path': 'generics_impl::Aaaaaaa',
+ 'name': 'bbbbbbb',
+ 'displayTypeSignature': '*Aaaaaaa* -> *u32*'
+ },
],
},
{
'query': 'Aaaaaaa -> bool',
'others': [
- { 'path': 'generics_impl::Aaaaaaa', 'name': 'ccccccc' },
+ {
+ 'path': 'generics_impl::Aaaaaaa',
+ 'name': 'ccccccc',
+ 'displayTypeSignature': '*Aaaaaaa* -> *bool*'
+ },
],
},
{
'query': 'Aaaaaaa -> usize',
'others': [
- { 'path': 'generics_impl::Aaaaaaa', 'name': 'read' },
+ {
+ 'path': 'generics_impl::Aaaaaaa',
+ 'name': 'read',
+ 'displayTypeSignature': '*Aaaaaaa*, [] -> Result<*usize*>'
+ },
],
},
{
'query': 'Read -> u64',
'others': [
- { 'path': 'generics_impl::Ddddddd', 'name': 'eeeeeee' },
- { 'path': 'generics_impl::Ddddddd', 'name': 'ggggggg' },
+ {
+ 'path': 'generics_impl::Ddddddd',
+ 'name': 'eeeeeee',
+ 'displayTypeSignature': 'impl *Read* -> *u64*'
+ },
+ {
+ 'path': 'generics_impl::Ddddddd',
+ 'name': 'ggggggg',
+ 'displayTypeSignature': 'Ddddddd -> *u64*'
+ },
],
},
{
'query': 'trait:Read -> u64',
'others': [
- { 'path': 'generics_impl::Ddddddd', 'name': 'eeeeeee' },
- { 'path': 'generics_impl::Ddddddd', 'name': 'ggggggg' },
+ {
+ 'path': 'generics_impl::Ddddddd',
+ 'name': 'eeeeeee',
+ 'displayTypeSignature': 'impl *Read* -> *u64*'
+ },
+ {
+ 'path': 'generics_impl::Ddddddd',
+ 'name': 'ggggggg',
+ 'displayTypeSignature': 'Ddddddd -> *u64*'
+ },
],
},
{
@@ -40,19 +68,31 @@ const EXPECTED = [
{
'query': 'bool -> u64',
'others': [
- { 'path': 'generics_impl::Ddddddd', 'name': 'fffffff' },
+ {
+ 'path': 'generics_impl::Ddddddd',
+ 'name': 'fffffff',
+ 'displayTypeSignature': '*bool* -> *u64*'
+ },
],
},
{
'query': 'Ddddddd -> u64',
'others': [
- { 'path': 'generics_impl::Ddddddd', 'name': 'ggggggg' },
+ {
+ 'path': 'generics_impl::Ddddddd',
+ 'name': 'ggggggg',
+ 'displayTypeSignature': '*Ddddddd* -> *u64*'
+ },
],
},
{
'query': '-> Ddddddd',
'others': [
- { 'path': 'generics_impl::Ddddddd', 'name': 'hhhhhhh' },
+ {
+ 'path': 'generics_impl::Ddddddd',
+ 'name': 'hhhhhhh',
+ 'displayTypeSignature': '-> *Ddddddd*'
+ },
],
},
];
diff --git a/tests/rustdoc-js/generics-match-ambiguity.js b/tests/rustdoc-js/generics-match-ambiguity.js
index edce4268c5ac7..247e66697d5d9 100644
--- a/tests/rustdoc-js/generics-match-ambiguity.js
+++ b/tests/rustdoc-js/generics-match-ambiguity.js
@@ -8,15 +8,31 @@ const EXPECTED = [
{
'query': 'Wrap',
'in_args': [
- { 'path': 'generics_match_ambiguity', 'name': 'bar' },
- { 'path': 'generics_match_ambiguity', 'name': 'foo' },
+ {
+ 'path': 'generics_match_ambiguity',
+ 'name': 'bar',
+ 'displayTypeSignature': '*Wrap*, Wrap'
+ },
+ {
+ 'path': 'generics_match_ambiguity',
+ 'name': 'foo',
+ 'displayTypeSignature': '*Wrap*, Wrap'
+ },
],
},
{
'query': 'Wrap',
'in_args': [
- { 'path': 'generics_match_ambiguity', 'name': 'bar' },
- { 'path': 'generics_match_ambiguity', 'name': 'foo' },
+ {
+ 'path': 'generics_match_ambiguity',
+ 'name': 'bar',
+ 'displayTypeSignature': '*Wrap*<*i32*, u32>, Wrap'
+ },
+ {
+ 'path': 'generics_match_ambiguity',
+ 'name': 'foo',
+ 'displayTypeSignature': '*Wrap*<*i32*>, Wrap'
+ },
],
},
{
diff --git a/tests/rustdoc-js/search-method-disambiguate.js b/tests/rustdoc-js/search-method-disambiguate.js
index 70aa895f99458..ddbae4ff4dd42 100644
--- a/tests/rustdoc-js/search-method-disambiguate.js
+++ b/tests/rustdoc-js/search-method-disambiguate.js
@@ -11,7 +11,8 @@ const EXPECTED = [
{
'path': 'search_method_disambiguate::MyTy',
'name': 'my_method',
- 'href': '../search_method_disambiguate/struct.MyTy.html#impl-X-for-MyTy%3Cbool%3E/method.my_method'
+ 'href': '../search_method_disambiguate/struct.MyTy.html#impl-X-for-MyTy%3Cbool%3E/method.my_method',
+ 'displayTypeSignature': '*MyTy* -> *bool*',
},
],
},
@@ -21,7 +22,8 @@ const EXPECTED = [
{
'path': 'search_method_disambiguate::MyTy',
'name': 'my_method',
- 'href': '../search_method_disambiguate/struct.MyTy.html#impl-X-for-MyTy%3Cu8%3E/method.my_method'
+ 'href': '../search_method_disambiguate/struct.MyTy.html#impl-X-for-MyTy%3Cu8%3E/method.my_method',
+ 'displayTypeSignature': '*MyTy* -> *u8*',
},
],
}
diff --git a/tests/rustdoc-js/type-parameters.js b/tests/rustdoc-js/type-parameters.js
index e695f189bb672..e637cb4fb254e 100644
--- a/tests/rustdoc-js/type-parameters.js
+++ b/tests/rustdoc-js/type-parameters.js
@@ -5,79 +5,79 @@ const EXPECTED = [
{
query: '-> trait:Some',
others: [
- { path: 'foo', name: 'alef' },
- { path: 'foo', name: 'alpha' },
+ { path: 'foo', name: 'alef', displayTypeSignature: '-> impl *Some*' },
+ { path: 'foo', name: 'alpha', displayTypeSignature: '-> impl *Some*' },
],
},
{
query: '-> generic:T',
others: [
- { path: 'foo', name: 'bet' },
- { path: 'foo', name: 'alef' },
- { path: 'foo', name: 'beta' },
+ { path: 'foo', name: 'bet', displayTypeSignature: '_ -> *T*' },
+ { path: 'foo', name: 'alef', displayTypeSignature: '-> *T*' },
+ { path: 'foo', name: 'beta', displayTypeSignature: 'T -> *T*' },
],
},
{
query: 'A -> B',
others: [
- { path: 'foo', name: 'bet' },
+ { path: 'foo', name: 'bet', displayTypeSignature: '*A* -> *B*' },
],
},
{
query: 'A -> A',
others: [
- { path: 'foo', name: 'beta' },
+ { path: 'foo', name: 'beta', displayTypeSignature: '*A* -> *A*' },
],
},
{
query: 'A, A',
others: [
- { path: 'foo', name: 'alternate' },
+ { path: 'foo', name: 'alternate', displayTypeSignature: '*A*, *A*' },
],
},
{
query: 'A, B',
others: [
- { path: 'foo', name: 'other' },
+ { path: 'foo', name: 'other', displayTypeSignature: '*A*, *B*' },
],
},
{
query: 'Other, Other',
others: [
- { path: 'foo', name: 'other' },
- { path: 'foo', name: 'alternate' },
+ { path: 'foo', name: 'other', displayTypeSignature: 'impl *Other*, impl *Other*' },
+ { path: 'foo', name: 'alternate', displayTypeSignature: 'impl *Other*, impl *Other*' },
],
},
{
query: 'generic:T',
in_args: [
- { path: 'foo', name: 'bet' },
- { path: 'foo', name: 'beta' },
- { path: 'foo', name: 'other' },
- { path: 'foo', name: 'alternate' },
+ { path: 'foo', name: 'bet', displayTypeSignature: '*T* -> _' },
+ { path: 'foo', name: 'beta', displayTypeSignature: '*T* -> T' },
+ { path: 'foo', name: 'other', displayTypeSignature: '*T*, _' },
+ { path: 'foo', name: 'alternate', displayTypeSignature: '*T*, T' },
],
},
{
query: 'generic:Other',
in_args: [
- { path: 'foo', name: 'bet' },
- { path: 'foo', name: 'beta' },
- { path: 'foo', name: 'other' },
- { path: 'foo', name: 'alternate' },
+ { path: 'foo', name: 'bet', displayTypeSignature: '*Other* -> _' },
+ { path: 'foo', name: 'beta', displayTypeSignature: '*Other* -> Other' },
+ { path: 'foo', name: 'other', displayTypeSignature: '*Other*, _' },
+ { path: 'foo', name: 'alternate', displayTypeSignature: '*Other*, Other' },
],
},
{
query: 'trait:Other',
in_args: [
- { path: 'foo', name: 'other' },
- { path: 'foo', name: 'alternate' },
+ { path: 'foo', name: 'other', displayTypeSignature: '_, impl *Other*' },
+ { path: 'foo', name: 'alternate', displayTypeSignature: 'impl *Other*, impl *Other*' },
],
},
{
query: 'Other',
in_args: [
- { path: 'foo', name: 'other' },
- { path: 'foo', name: 'alternate' },
+ { path: 'foo', name: 'other', displayTypeSignature: '_, impl *Other*' },
+ { path: 'foo', name: 'alternate', displayTypeSignature: 'impl *Other*, impl *Other*' },
],
},
{