mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Adjust ranking so that duplicates count against rank
This commit is contained in:
parent
12dc24f460
commit
9900ea48b5
@ -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<number>} 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) {
|
||||
|
@ -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'
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
13
tests/rustdoc-js-std/transmute-fail.js
Normal file
13
tests/rustdoc-js-std/transmute-fail.js
Normal file
@ -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' },
|
||||
],
|
||||
},
|
||||
];
|
12
tests/rustdoc-js-std/transmute.js
Normal file
12
tests/rustdoc-js-std/transmute.js
Normal file
@ -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' },
|
||||
],
|
||||
},
|
||||
];
|
@ -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' },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
@ -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' },
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user