From a994f46421f5ac551905e336c1c1b78a8885f6a5 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 23 Nov 2023 17:16:19 -0800 Subject: [PATCH 1/2] Add test of rustdoc sort order for stable vs unstable item --- tests/rustdoc/stability.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/rustdoc/stability.rs b/tests/rustdoc/stability.rs index 90be2050d926b..5d8286d8116f2 100644 --- a/tests/rustdoc/stability.rs +++ b/tests/rustdoc/stability.rs @@ -2,6 +2,14 @@ #![unstable(feature = "test", issue = "none")] +// @has stability/index.html +// @has - '//ul[@class="item-table"]/li[1]//a' Unstable +// @has - '//ul[@class="item-table"]/li[2]//a' AaStable +// @has - '//ul[@class="item-table"]/li[3]//a' ZzStable + +#[stable(feature = "rust2", since = "2.2.2")] +pub struct AaStable; + pub struct Unstable { // @has stability/struct.Unstable.html \ // '//span[@class="item-info"]//div[@class="stab unstable"]' \ @@ -10,3 +18,6 @@ pub struct Unstable { pub foo: u32, pub bar: u32, } + +#[stable(feature = "rust2", since = "2.2.2")] +pub struct ZzStable; From b77aa74a2d6b0b5cac167a942a7c53931dc715c9 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 23 Nov 2023 16:38:31 -0800 Subject: [PATCH 2/2] Sort unstable items last in rustdoc, instead of first --- src/librustdoc/html/render/print_item.rs | 4 ++-- tests/rustdoc/stability.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 927bec4251e57..ce9e1bcf4883a 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -369,8 +369,8 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items: if let (Some(a), Some(b)) = (s1, s2) { match (a.is_stable(), b.is_stable()) { (true, true) | (false, false) => {} - (false, true) => return Ordering::Less, - (true, false) => return Ordering::Greater, + (false, true) => return Ordering::Greater, + (true, false) => return Ordering::Less, } } let lhs = i1.name.unwrap_or(kw::Empty); diff --git a/tests/rustdoc/stability.rs b/tests/rustdoc/stability.rs index 5d8286d8116f2..c4d7118d07ff0 100644 --- a/tests/rustdoc/stability.rs +++ b/tests/rustdoc/stability.rs @@ -3,9 +3,9 @@ #![unstable(feature = "test", issue = "none")] // @has stability/index.html -// @has - '//ul[@class="item-table"]/li[1]//a' Unstable -// @has - '//ul[@class="item-table"]/li[2]//a' AaStable -// @has - '//ul[@class="item-table"]/li[3]//a' ZzStable +// @has - '//ul[@class="item-table"]/li[1]//a' AaStable +// @has - '//ul[@class="item-table"]/li[2]//a' ZzStable +// @has - '//ul[@class="item-table"]/li[3]//a' Unstable #[stable(feature = "rust2", since = "2.2.2")] pub struct AaStable;