about summary refs log tree commit diff
path: root/src/librustdoc/html/render/mod.rs
diff options
context:
space:
mode:
authorbinarycat <binarycat@envs.net>2025-05-27 12:42:25 -0500
committerbinarycat <binarycat@envs.net>2025-06-10 12:56:58 -0500
commit1140e90074b0cbcfdea8535e4b51877e2838227e (patch)
treef3f3b850ab68799f03620f47e021b9e4163bb398 /src/librustdoc/html/render/mod.rs
parentccf3198de316b488ee17441935182e9d5292b4d3 (diff)
downloadrust-1140e90074b0cbcfdea8535e4b51877e2838227e.tar.gz
rust-1140e90074b0cbcfdea8535e4b51877e2838227e.zip
rustdoc search: prefer stable items in search results
fixes https://github.com/rust-lang/rust/issues/138067
Diffstat (limited to 'src/librustdoc/html/render/mod.rs')
-rw-r--r--src/librustdoc/html/render/mod.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index 66d5aafa3c1..29917bb0fca 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -50,7 +50,8 @@ use std::{fs, str};
 use askama::Template;
 use itertools::Either;
 use rustc_attr_data_structures::{
-    ConstStability, DeprecatedSince, Deprecation, RustcVersion, StabilityLevel, StableSince,
+    ConstStability, DeprecatedSince, Deprecation, RustcVersion, Stability, StabilityLevel,
+    StableSince,
 };
 use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
 use rustc_hir::Mutability;
@@ -140,6 +141,12 @@ pub(crate) struct IndexItem {
     pub(crate) search_type: Option<IndexItemFunctionType>,
     pub(crate) aliases: Box<[Symbol]>,
     pub(crate) deprecation: Option<Deprecation>,
+    pub(crate) stability: Option<Stability>,
+}
+impl IndexItem {
+    fn is_unstable(&self) -> bool {
+        matches!(&self.stability, Some(Stability { level: StabilityLevel::Unstable { .. }, .. }))
+    }
 }
 
 /// A type used for the search index.