Skip to content

Commit 98bae81

Browse files
authored
Rollup merge of rust-lang#118224 - dtolnay:rustdocsortunstable, r=fmease
Sort unstable items last in rustdoc, instead of first As far as I can tell, this is a bug introduced inadvertently by rust-lang#77817 in Rust 1.49. Older toolchains used to sort unstable items last. Notice how in the code before that PR, `(Unstable, Stable) => return Ordering::Greater` in src/librustdoc/html/render/mod.rs. Whereas after that PR, `(Unstable, Stable) => return Ordering::Less`. Compare https://doc.rust-lang.org/1.48.0/std/marker/index.html vs https://doc.rust-lang.org/1.49.0/std/marker/index.html.
2 parents b2d6480 + b77aa74 commit 98bae81

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/librustdoc/html/render/print_item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,8 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
369369
if let (Some(a), Some(b)) = (s1, s2) {
370370
match (a.is_stable(), b.is_stable()) {
371371
(true, true) | (false, false) => {}
372-
(false, true) => return Ordering::Less,
373-
(true, false) => return Ordering::Greater,
372+
(false, true) => return Ordering::Greater,
373+
(true, false) => return Ordering::Less,
374374
}
375375
}
376376
let lhs = i1.name.unwrap_or(kw::Empty);

tests/rustdoc/stability.rs

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
#![unstable(feature = "test", issue = "none")]
44

5+
// @has stability/index.html
6+
// @has - '//ul[@class="item-table"]/li[1]//a' AaStable
7+
// @has - '//ul[@class="item-table"]/li[2]//a' ZzStable
8+
// @has - '//ul[@class="item-table"]/li[3]//a' Unstable
9+
10+
#[stable(feature = "rust2", since = "2.2.2")]
11+
pub struct AaStable;
12+
513
pub struct Unstable {
614
// @has stability/struct.Unstable.html \
715
// '//span[@class="item-info"]//div[@class="stab unstable"]' \
@@ -10,3 +18,6 @@ pub struct Unstable {
1018
pub foo: u32,
1119
pub bar: u32,
1220
}
21+
22+
#[stable(feature = "rust2", since = "2.2.2")]
23+
pub struct ZzStable;

0 commit comments

Comments
 (0)