diff options
| author | binarycat <binarycat@envs.net> | 2025-06-10 13:35:46 -0500 |
|---|---|---|
| committer | binarycat <binarycat@envs.net> | 2025-08-08 11:40:03 -0500 |
| commit | 5e8ebd5ecd8546591a6707ac9e1a3b8a64c72f76 (patch) | |
| tree | b7453c5a9df4ce7e890e4a3c5c45dbe0ea6f8dba | |
| parent | 1140e90074b0cbcfdea8535e4b51877e2838227e (diff) | |
| download | rust-5e8ebd5ecd8546591a6707ac9e1a3b8a64c72f76.tar.gz rust-5e8ebd5ecd8546591a6707ac9e1a3b8a64c72f76.zip | |
rustdoc: IndexItem::{stability -> is_unstable}
| -rw-r--r-- | src/librustdoc/formats/cache.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/html/render/mod.rs | 10 | ||||
| -rw-r--r-- | src/librustdoc/html/render/search_index.rs | 4 |
3 files changed, 5 insertions, 11 deletions
diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index c3251ca7806..d0dbc5a74da 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -586,7 +586,7 @@ fn add_item_to_search_index(tcx: TyCtxt<'_>, cache: &mut Cache, item: &clean::It search_type, aliases, deprecation, - stability: item.stability(tcx), + is_unstable: item.stability(tcx).map(|x| x.is_unstable()).unwrap_or(false), }; cache.search_index.push(index_item); } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 29917bb0fca..81c05d93f82 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -50,8 +50,7 @@ use std::{fs, str}; use askama::Template; use itertools::Either; use rustc_attr_data_structures::{ - ConstStability, DeprecatedSince, Deprecation, RustcVersion, Stability, StabilityLevel, - StableSince, + ConstStability, DeprecatedSince, Deprecation, RustcVersion, StabilityLevel, StableSince, }; use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; use rustc_hir::Mutability; @@ -141,12 +140,7 @@ 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 { .. }, .. })) - } + pub(crate) is_unstable: bool, } /// A type used for the search index. diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index 6635aa02e97..a0911bf5873 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -93,7 +93,7 @@ pub(crate) fn build_index( ), aliases: item.attrs.get_doc_aliases(), deprecation: item.deprecation(tcx), - stability: item.stability(tcx), + is_unstable: item.stability(tcx).is_some_and(|x| x.is_unstable()), }); } } @@ -700,7 +700,7 @@ pub(crate) fn build_index( // bitmasks always use 1-indexing for items, with 0 as the crate itself deprecated.push(u32::try_from(index + 1).unwrap()); } - if item.is_unstable() { + if item.is_unstable { unstable.push(u32::try_from(index + 1).unwrap()); } } |
