Skip to content

Commit a195cf6

Browse files
Revert "rustdoc search: prefer stable items in search results"
This reverts commit 1140e90.
1 parent 2820fcc commit a195cf6

File tree

10 files changed

+5
-65
lines changed

10 files changed

+5
-65
lines changed

src/librustdoc/formats/cache.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,6 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It
602602
search_type,
603603
aliases,
604604
deprecation,
605-
stability: item.stability(tcx),
606605
};
607606
cache.search_index.push(index_item);
608607
}

src/librustdoc/html/render/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,6 @@ pub(crate) struct IndexItem {
139139
pub(crate) search_type: Option<IndexItemFunctionType>,
140140
pub(crate) aliases: Box<[Symbol]>,
141141
pub(crate) deprecation: Option<Deprecation>,
142-
pub(crate) stability: Option<Stability>,
143-
}
144-
impl IndexItem {
145-
fn is_unstable(&self) -> bool {
146-
matches!(&self.stability, Some(Stability { level: StabilityLevel::Unstable { .. }, .. }))
147-
}
148142
}
149143

150144
/// A type used for the search index.

src/librustdoc/html/render/search_index.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ pub(crate) fn build_index(
9393
),
9494
aliases: item.attrs.get_doc_aliases(),
9595
deprecation: item.deprecation(tcx),
96-
stability: item.stability(tcx),
9796
});
9897
}
9998
}
@@ -656,7 +655,6 @@ pub(crate) fn build_index(
656655
let mut parents_backref_queue = VecDeque::new();
657656
let mut functions = String::with_capacity(self.items.len());
658657
let mut deprecated = Vec::with_capacity(self.items.len());
659-
let mut unstable = Vec::with_capacity(self.items.len());
660658

661659
let mut type_backref_queue = VecDeque::new();
662660

@@ -713,9 +711,6 @@ pub(crate) fn build_index(
713711
// bitmasks always use 1-indexing for items, with 0 as the crate itself
714712
deprecated.push(u32::try_from(index + 1).unwrap());
715713
}
716-
if item.is_unstable() {
717-
unstable.push(u32::try_from(index + 1).unwrap());
718-
}
719714
}
720715

721716
for (index, path) in &revert_extra_paths {
@@ -754,7 +749,6 @@ pub(crate) fn build_index(
754749
crate_data.serialize_field("r", &re_exports)?;
755750
crate_data.serialize_field("b", &self.associated_item_disambiguators)?;
756751
crate_data.serialize_field("c", &bitmap_to_string(&deprecated))?;
757-
crate_data.serialize_field("u", &bitmap_to_string(&unstable))?;
758752
crate_data.serialize_field("e", &bitmap_to_string(&self.empty_desc))?;
759753
crate_data.serialize_field("P", &param_names)?;
760754
if has_aliases {

src/librustdoc/html/static/js/rustdoc.d.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ declare namespace rustdoc {
129129

130130
/**
131131
* A single parsed "atom" in a search query. For example,
132-
*
132+
*
133133
* std::fmt::Formatter, Write -> Result<()>
134134
* ┏━━━━━━━━━━━━━━━━━━ ┌──── ┏━━━━━┅┅┅┅┄┄┄┄┄┄┄┄┄┄┄┄┄┄┐
135135
* ┃ │ ┗ QueryElement { ┊
@@ -449,8 +449,6 @@ declare namespace rustdoc {
449449
* of `p`) but is used for modules items like free functions.
450450
*
451451
* `c` is an array of item indices that are deprecated.
452-
*
453-
* `u` is an array of item indices that are unstable.
454452
*/
455453
type RawSearchIndexCrate = {
456454
doc: string,
@@ -465,7 +463,6 @@ declare namespace rustdoc {
465463
p: Array<[number, string] | [number, string, number] | [number, string, number, number] | [number, string, number, number, string]>,
466464
b: Array<[number, String]>,
467465
c: string,
468-
u: string,
469466
r: Array<[number, number]>,
470467
P: Array<[number, string]>,
471468
};

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

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,11 +1464,6 @@ class DocSearch {
14641464
* @type {Map<String, RoaringBitmap>}
14651465
*/
14661466
this.searchIndexEmptyDesc = new Map();
1467-
/**
1468-
* @type {Map<String, RoaringBitmap>}
1469-
*/
1470-
this.searchIndexUnstable = new Map();
1471-
14721467
/**
14731468
* @type {Uint32Array}
14741469
*/
@@ -2057,10 +2052,9 @@ class DocSearch {
20572052
};
20582053
const descShardList = [descShard];
20592054

2060-
// Deprecated and unstable items and items with no description
2055+
// Deprecated items and items with no description
20612056
this.searchIndexDeprecated.set(crate, new RoaringBitmap(crateCorpus.c));
20622057
this.searchIndexEmptyDesc.set(crate, new RoaringBitmap(crateCorpus.e));
2063-
this.searchIndexUnstable.set(crate, new RoaringBitmap(crateCorpus.u));
20642058
let descIndex = 0;
20652059

20662060
/**
@@ -3332,19 +3326,6 @@ class DocSearch {
33323326
return a - b;
33333327
}
33343328

3335-
// sort unstable items later
3336-
a = Number(
3337-
// @ts-expect-error
3338-
this.searchIndexUnstable.get(aaa.item.crate).contains(aaa.item.bitIndex),
3339-
);
3340-
b = Number(
3341-
// @ts-expect-error
3342-
this.searchIndexUnstable.get(bbb.item.crate).contains(bbb.item.bitIndex),
3343-
);
3344-
if (a !== b) {
3345-
return a - b;
3346-
}
3347-
33483329
// sort by crate (current crate comes first)
33493330
a = Number(aaa.item.crate !== preferredCrate);
33503331
b = Number(bbb.item.crate !== preferredCrate);

tests/rustdoc-js-std/core-transmute.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ const EXPECTED = [
33
{
44
'query': 'generic:T -> generic:U',
55
'others': [
6-
{ 'path': 'core::mem', 'name': 'transmute' },
76
{ 'path': 'core::intrinsics::simd', 'name': 'simd_as' },
87
{ 'path': 'core::intrinsics::simd', 'name': 'simd_cast' },
8+
{ 'path': 'core::mem', 'name': 'transmute' },
99
],
1010
},
1111
];

tests/rustdoc-js-std/transmute-fail.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ const EXPECTED = [
66
// should-fail tag and the search query below:
77
'query': 'generic:T -> generic:T',
88
'others': [
9-
{ 'path': 'std::mem', 'name': 'transmute' },
109
{ 'path': 'std::intrinsics::simd', 'name': 'simd_as' },
1110
{ 'path': 'std::intrinsics::simd', 'name': 'simd_cast' },
11+
{ 'path': 'std::mem', 'name': 'transmute' },
1212
],
1313
},
1414
];

tests/rustdoc-js-std/transmute.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ const EXPECTED = [
55
// should-fail tag and the search query below:
66
'query': 'generic:T -> generic:U',
77
'others': [
8-
{ 'path': 'std::mem', 'name': 'transmute' },
98
{ 'path': 'std::intrinsics::simd', 'name': 'simd_as' },
109
{ 'path': 'std::intrinsics::simd', 'name': 'simd_cast' },
10+
{ 'path': 'std::mem', 'name': 'transmute' },
1111
],
1212
},
1313
];

tests/rustdoc-js/sort-stability.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/rustdoc-js/sort-stability.rs

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)