diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js
index d269c9322a3..4e1bbbbf59d 100644
--- a/src/librustdoc/html/static/js/search.js
+++ b/src/librustdoc/html/static/js/search.js
@@ -1412,7 +1412,7 @@ class DocSearch {
* query fingerprint. If any bits are set in the query but not in the function, it can't
* match.
*
- * - The fourth section has the number of distinct items in the set.
+ * - The fourth section has the number of items in the set.
* This is the distance function, used for filtering and for sorting.
*
* [^1]: Distance is the relatively naive metric of counting the number of distinct items in
@@ -1420,9 +1420,8 @@ class DocSearch {
*
* @param {FunctionType|QueryElement} type - a single type
* @param {Uint32Array} output - write the fingerprint to this data structure: uses 128 bits
- * @param {Set} fps - Set of distinct items
*/
- buildFunctionTypeFingerprint(type, output, fps) {
+ buildFunctionTypeFingerprint(type, output) {
let input = type.id;
// All forms of `[]`/`()`/`->` get collapsed down to one thing in the bloom filter.
// Differentiating between arrays and slices, if the user asks for it, is
@@ -1468,10 +1467,11 @@ class DocSearch {
output[0] |= (1 << (h0a % 32)) | (1 << (h1b % 32));
output[1] |= (1 << (h1a % 32)) | (1 << (h2b % 32));
output[2] |= (1 << (h2a % 32)) | (1 << (h0b % 32));
- fps.add(input);
+ // output[3] is the total number of items in the type signature
+ output[3] += 1;
}
for (const g of type.generics) {
- this.buildFunctionTypeFingerprint(g, output, fps);
+ this.buildFunctionTypeFingerprint(g, output);
}
const fb = {
id: null,
@@ -1482,9 +1482,8 @@ class DocSearch {
for (const [k, v] of type.bindings.entries()) {
fb.id = k;
fb.generics = v;
- this.buildFunctionTypeFingerprint(fb, output, fps);
+ this.buildFunctionTypeFingerprint(fb, output);
}
- output[3] = fps.size;
}
/**
@@ -1734,16 +1733,15 @@ class DocSearch {
if (type !== null) {
if (type) {
const fp = this.functionTypeFingerprint.subarray(id * 4, (id + 1) * 4);
- const fps = new Set();
for (const t of type.inputs) {
- this.buildFunctionTypeFingerprint(t, fp, fps);
+ this.buildFunctionTypeFingerprint(t, fp);
}
for (const t of type.output) {
- this.buildFunctionTypeFingerprint(t, fp, fps);
+ this.buildFunctionTypeFingerprint(t, fp);
}
for (const w of type.where_clause) {
for (const t of w) {
- this.buildFunctionTypeFingerprint(t, fp, fps);
+ this.buildFunctionTypeFingerprint(t, fp);
}
}
}
@@ -3885,14 +3883,13 @@ class DocSearch {
);
};
- const fps = new Set();
for (const elem of parsedQuery.elems) {
convertNameToId(elem);
- this.buildFunctionTypeFingerprint(elem, parsedQuery.typeFingerprint, fps);
+ this.buildFunctionTypeFingerprint(elem, parsedQuery.typeFingerprint);
}
for (const elem of parsedQuery.returned) {
convertNameToId(elem);
- this.buildFunctionTypeFingerprint(elem, parsedQuery.typeFingerprint, fps);
+ this.buildFunctionTypeFingerprint(elem, parsedQuery.typeFingerprint);
}
if (parsedQuery.foundElems === 1 && !parsedQuery.hasReturnArrow) {
diff --git a/tests/rustdoc-js-std/simd-type-signatures.js b/tests/rustdoc-js-std/simd-type-signatures.js
index c07f15dcbe8..4fc14e65ac4 100644
--- a/tests/rustdoc-js-std/simd-type-signatures.js
+++ b/tests/rustdoc-js-std/simd-type-signatures.js
@@ -20,11 +20,6 @@ const EXPECTED = [
'name': 'simd_min',
'href': '../std/simd/prelude/struct.Simd.html#impl-SimdOrd-for-Simd%3Ci16,+N%3E/method.simd_min'
},
- {
- 'path': 'std::simd::prelude::Simd',
- 'name': 'simd_clamp',
- 'href': '../std/simd/prelude/struct.Simd.html#impl-SimdOrd-for-Simd%3Ci16,+N%3E/method.simd_clamp'
- },
{
'path': 'std::simd::prelude::Simd',
'name': 'saturating_add',
@@ -35,6 +30,11 @@ const EXPECTED = [
'name': 'saturating_sub',
'href': '../std/simd/prelude/struct.Simd.html#impl-SimdInt-for-Simd%3Ci16,+N%3E/method.saturating_sub'
},
+ {
+ 'path': 'std::simd::prelude::Simd',
+ 'name': 'simd_clamp',
+ 'href': '../std/simd/prelude/struct.Simd.html#impl-SimdOrd-for-Simd%3Ci16,+N%3E/method.simd_clamp'
+ },
],
},
{
@@ -50,11 +50,6 @@ const EXPECTED = [
'name': 'simd_min',
'href': '../std/simd/prelude/struct.Simd.html#impl-SimdOrd-for-Simd%3Ci8,+N%3E/method.simd_min'
},
- {
- 'path': 'std::simd::prelude::Simd',
- 'name': 'simd_clamp',
- 'href': '../std/simd/prelude/struct.Simd.html#impl-SimdOrd-for-Simd%3Ci8,+N%3E/method.simd_clamp'
- },
{
'path': 'std::simd::prelude::Simd',
'name': 'saturating_add',
@@ -65,6 +60,11 @@ const EXPECTED = [
'name': 'saturating_sub',
'href': '../std/simd/prelude/struct.Simd.html#impl-SimdInt-for-Simd%3Ci8,+N%3E/method.saturating_sub'
},
+ {
+ 'path': 'std::simd::prelude::Simd',
+ 'name': 'simd_clamp',
+ 'href': '../std/simd/prelude/struct.Simd.html#impl-SimdOrd-for-Simd%3Ci8,+N%3E/method.simd_clamp'
+ },
],
},
];
diff --git a/tests/rustdoc-js-std/transmute-fail.js b/tests/rustdoc-js-std/transmute-fail.js
new file mode 100644
index 00000000000..c4dddf3cf3c
--- /dev/null
+++ b/tests/rustdoc-js-std/transmute-fail.js
@@ -0,0 +1,13 @@
+// should-fail
+const EXPECTED = [
+ {
+ // Keep this test case identical to `transmute`, except the
+ // should-fail tag and the search query below:
+ 'query': 'generic:T -> generic:T',
+ 'others': [
+ { 'path': 'std::intrinsics::simd', 'name': 'simd_as' },
+ { 'path': 'std::intrinsics::simd', 'name': 'simd_cast' },
+ { 'path': 'std::intrinsics', 'name': 'transmute' },
+ ],
+ },
+];
diff --git a/tests/rustdoc-js-std/transmute.js b/tests/rustdoc-js-std/transmute.js
new file mode 100644
index 00000000000..0e52e21e0de
--- /dev/null
+++ b/tests/rustdoc-js-std/transmute.js
@@ -0,0 +1,12 @@
+const EXPECTED = [
+ {
+ // Keep this test case identical to `transmute-fail`, except the
+ // should-fail tag and the search query below:
+ 'query': 'generic:T -> generic:U',
+ 'others': [
+ { 'path': 'std::intrinsics::simd', 'name': 'simd_as' },
+ { 'path': 'std::intrinsics::simd', 'name': 'simd_cast' },
+ { 'path': 'std::intrinsics', 'name': 'transmute' },
+ ],
+ },
+];
diff --git a/tests/rustdoc-js/impl-trait.js b/tests/rustdoc-js/impl-trait.js
index 8bb3f2d3e99..3d7d0ca5bcd 100644
--- a/tests/rustdoc-js/impl-trait.js
+++ b/tests/rustdoc-js/impl-trait.js
@@ -23,8 +23,8 @@ const EXPECTED = [
'others': [
{ 'path': 'impl_trait', 'name': 'bbbbbbb' },
{ 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' },
- { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
{ 'path': 'impl_trait::Ccccccc', 'name': 'ggggggg' },
+ { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
],
},
{
@@ -39,14 +39,14 @@ const EXPECTED = [
{ 'path': 'impl_trait', 'name': 'Aaaaaaa' },
],
'in_args': [
- { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
{ 'path': 'impl_trait::Ccccccc', 'name': 'eeeeeee' },
+ { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
],
'returned': [
{ 'path': 'impl_trait', 'name': 'bbbbbbb' },
{ 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' },
- { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
{ 'path': 'impl_trait::Ccccccc', 'name': 'ggggggg' },
+ { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
],
},
];
diff --git a/tests/rustdoc-js/type-parameters.js b/tests/rustdoc-js/type-parameters.js
index e045409e507..fa2b8d2ebfd 100644
--- a/tests/rustdoc-js/type-parameters.js
+++ b/tests/rustdoc-js/type-parameters.js
@@ -11,9 +11,9 @@ const EXPECTED = [
{
query: '-> generic:T',
others: [
- { path: 'foo', name: 'beta' },
{ path: 'foo', name: 'bet' },
{ path: 'foo', name: 'alef' },
+ { path: 'foo', name: 'beta' },
],
},
{
@@ -50,8 +50,8 @@ const EXPECTED = [
{
query: 'generic:T',
in_args: [
- { path: 'foo', name: 'beta' },
{ path: 'foo', name: 'bet' },
+ { path: 'foo', name: 'beta' },
{ path: 'foo', name: 'alternate' },
{ path: 'foo', name: 'other' },
],
@@ -59,8 +59,8 @@ const EXPECTED = [
{
query: 'generic:Other',
in_args: [
- { path: 'foo', name: 'beta' },
{ path: 'foo', name: 'bet' },
+ { path: 'foo', name: 'beta' },
{ path: 'foo', name: 'alternate' },
{ path: 'foo', name: 'other' },
],