Skip to content

Commit a1dc0ab

Browse files
committed
rustdoc-search: rank re-export lower
Fixes a side effect of 127a5d9 reported on Zulip.
1 parent 16d1ffa commit a1dc0ab

6 files changed

Lines changed: 45 additions & 2 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2884,6 +2884,13 @@ class DocSearch {
28842884
return a - b;
28852885
}
28862886

2887+
// sort re-exports lower
2888+
a = Number(aai.ty === itemTypes.import);
2889+
b = Number(bbi.ty === itemTypes.import);
2890+
if (a !== b) {
2891+
return a - b;
2892+
}
2893+
28872894
// sort deprecated items later
28882895
a = Number(aai.deprecated);
28892896
b = Number(bbi.deprecated);

‎tests/rustdoc-js-std/println-typo.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const EXPECTED = {
88
{ 'path': 'std', 'name': 'println' },
99
{ 'path': 'std::prelude::v1', 'name': 'println' },
1010
{ 'path': 'std', 'name': 'print' },
11-
{ 'path': 'std::prelude::v1', 'name': 'print' },
1211
{ 'path': 'std', 'name': 'eprintln' },
12+
{ 'path': 'std::prelude::v1', 'name': 'print' },
1313
{ 'path': 'std::prelude::v1', 'name': 'eprintln' },
1414
],
1515
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//@ edition:2021
2+
3+
#![crate_name = "zzzzz"]
4+
pub struct Eepy;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// This test ensures that imports have lower ranking than other matches,
2+
// even if those matches have shorter names.
3+
4+
const EXPECTED = [
5+
{
6+
'query': 'Eepy',
7+
'others': [
8+
{ 'path': 'zzzzz', 'name': 'Eepy' },
9+
],
10+
},
11+
{
12+
'query': 'zzzzz::Eepy',
13+
'others': [
14+
{ 'path': 'zzzzz', 'name': 'Eepy' },
15+
],
16+
},
17+
{
18+
'query': 'foo::Eepy',
19+
'others': [
20+
{ 'path': 'foo', 'name': 'Eepy' },
21+
],
22+
},
23+
];
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ aux-crate:zzzzz=zzzzz.rs
2+
//@ aux-build:zzzzz.rs
3+
//@ build-aux-docs
4+
//@ edition:2021
5+
6+
#![crate_name = "foo"]
7+
8+
#[doc(no_inline)]
9+
pub use zzzzz::Eepy;

‎tests/rustdoc-js/reexport-dedup.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const EXPECTED = [
44
{
55
'query': 'Subscriber',
66
'others': [
7-
{ 'path': 'foo', 'name': 'Subscriber' },
7+
{ 'path': 'foo::fmt', 'name': 'Subscriber' },
88
],
99
},
1010
{

0 commit comments

Comments
 (0)