Skip to content

Commit d105953

Browse files
Rollup merge of #145389 - GuillaumeGomez:unstable-search, r=fmease
[rustdoc] Revert "rustdoc search: prefer stable items in search results" Reverts #141658 and reverts #145349. Reopens #138067. r? `@fmease`
2 parents f95a0e4 + a195cf6 commit d105953

File tree

10 files changed

+5
-68
lines changed

10 files changed

+5
-68
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-
is_unstable: item.stability(tcx).map(|x| x.is_unstable()).unwrap_or(false),
606605
};
607606
cache.search_index.push(index_item);
608607
}

src/librustdoc/html/render/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +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) is_unstable: bool,
143142
}
144143

145144
/// 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-
is_unstable: item.stability(tcx).is_some_and(|x| x.is_unstable()),
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 & 28 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,12 +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-
if (crateCorpus.u !== undefined && crateCorpus.u !== null) {
2064-
this.searchIndexUnstable.set(crate, new RoaringBitmap(crateCorpus.u));
2065-
}
20662058
let descIndex = 0;
20672059

20682060
/**
@@ -3334,25 +3326,6 @@ class DocSearch {
33343326
return a - b;
33353327
}
33363328

3337-
// sort unstable items later
3338-
// FIXME: there is some doubt if this is the most effecient way to implement this.
3339-
// alternative options include:
3340-
// * put is_unstable on each item when the index is built.
3341-
// increases memory usage but avoids a hashmap lookup.
3342-
// * put is_unstable on each item before sorting.
3343-
// better worst case performance but worse average case performance.
3344-
a = Number(
3345-
// @ts-expect-error
3346-
this.searchIndexUnstable.get(aaa.item.crate).contains(aaa.item.bitIndex),
3347-
);
3348-
b = Number(
3349-
// @ts-expect-error
3350-
this.searchIndexUnstable.get(bbb.item.crate).contains(bbb.item.bitIndex),
3351-
);
3352-
if (a !== b) {
3353-
return a - b;
3354-
}
3355-
33563329
// sort by crate (current crate comes first)
33573330
a = Number(aaa.item.crate !== preferredCrate);
33583331
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)