From 8d273dbda58197209df9f358df6f037acacb91ef Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 24 Jun 2026 23:51:15 +0200 Subject: [PATCH] Update to new rustdoc-json output --- CHANGELOG.md | 10 ++++++++ COMMIT.txt | 2 +- Cargo.lock | 2 +- Cargo.toml | 2 +- src/lib.rs | 64 +++++++++++++++++++++++++++++++++++++++++++++++++--- 5 files changed, 74 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa24ec2..9f96547 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ + +# [v0.58.0](https://github.com/rust-lang/rustdoc-types/releases/tag/v0.58.0) - 2026-06-24 + +**Breaking change**: Add `Item::stability` field +([rust#158230](https://github.com/rust-lang/rust/pull/158230)) + +- Format Version: 57 +- Upstream Commit: [`fee82a37e9eabf8afe6db62c0177baaf63356a98`](https://github.com/rust-lang/rust/commit/fee82a37e9eabf8afe6db62c0177baaf63356a98) +- Diff: [v0.57.3...v0.57.4](https://github.com/rust-lang/rustdoc-types/compare/v0.57.3...v0.57.4) + # [v0.57.4](https://github.com/rust-lang/rustdoc-types/releases/tag/v0.57.4) - 2026-06-19 diff --git a/COMMIT.txt b/COMMIT.txt index 2c87d40..b60b364 100644 --- a/COMMIT.txt +++ b/COMMIT.txt @@ -1 +1 @@ -fee82a37e9eabf8afe6db62c0177baaf63356a98 +818d29d02798f5e48d28c868e4034294a7a38597 diff --git a/Cargo.lock b/Cargo.lock index 248ad78..22c9e12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -271,7 +271,7 @@ checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" [[package]] name = "rustdoc-types" -version = "0.57.4" +version = "0.58.0" dependencies = [ "postcard", "rkyv", diff --git a/Cargo.toml b/Cargo.toml index 9aa627e..daa41c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustdoc-types" -version = "0.57.4" +version = "0.58.0" edition = "2018" license = "MIT OR Apache-2.0" description = "Types for rustdoc's json output" diff --git a/src/lib.rs b/src/lib.rs index 21ad51f..f248646 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -113,8 +113,8 @@ use serde_derive::{Deserialize, Serialize}; // will instead cause conflicts. See #94591 for more. (This paragraph and the "Latest feature" line // are deliberately not in a doc comment, because they need not be in public docs.) // -// Latest feature: Add `ExternCrate::path`. -pub const FORMAT_VERSION: u32 = 57; +// Latest feature: Add `Item::stability`. +pub const FORMAT_VERSION: u32 = 58; /// The root of the emitted JSON blob. /// @@ -281,7 +281,10 @@ pub struct Item { pub links: HashMap, /// Attributes on this item. /// - /// Does not include `#[deprecated]` attributes: see the [`Self::deprecation`] field instead. + /// Does not include: + /// - `#[doc = "Doc Comment"]` or `/// Doc comment`: see [`Self::docs`] instead. + /// - `#[deprecated]` attributes: see the [`Self::deprecation`] field instead. + /// - `#[stable]` and `#[unstable]` attributes: see the [`Self::stability`] field instead. /// /// Attributes appear in pretty-printed Rust form, regardless of their formatting /// in the original source code. For example: @@ -293,10 +296,64 @@ pub struct Item { pub attrs: Vec, /// Information about the item’s deprecation, if present. pub deprecation: Option, + + /// Stability information for this item, if any. + /// + /// This describes whether the item itself is stable or unstable, as noted by a `#[stable]` or + /// `#[unstable]` attribute. It does not capture const stability, default-body stability, etc. + /// + /// Whether a path to an item is stable depends on the stability of containing modules + /// or re-exports along that path. For example, a stable item can be reachable through both an + /// unstable module and a stable re-export. + /// + /// For items whose inner kind is [`ItemEnum::Use`], this is the stability of the import itself, + /// not the item being imported. This allows users to determine the stability of paths + /// that involve re-exports. + /// + /// Associated items can inherit instability from their enclosing unstable trait or impl. + /// Unannotated associated items in stable traits or impls may have no separate stability value. + /// + /// Currently, Rust's `#[stable]` and `#[unstable]` attributes are themselves not stable. + /// As a result, this field is primarily populated for standard-library items; + /// most ordinary third-party crates usually have no data here. + pub stability: Option>, + /// The type-specific fields describing this item. pub inner: ItemEnum, } +/// Stability information for an item. +/// +/// This only refers to regular item stability: whether the item is stable or unstable +/// as represented by the `#[stable]` or `#[unstable]` attributes. +/// Const stability and default-body stability are different things and not captured here. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[cfg_attr(feature = "rkyv_0_8", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))] +#[cfg_attr(feature = "rkyv_0_8", rkyv(derive(Debug)))] +pub struct Stability { + /// The stability feature associated with this item. + /// + /// For unstable items, this is the feature gate associated with the item. + /// For stable items, this is the historical label recorded when the item was stabilized. + pub feature: String, + + #[serde(flatten)] + pub level: StabilityLevel, +} + +/// Whether an item is stable or unstable as regular public API. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[cfg_attr(feature = "rkyv_0_8", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))] +#[cfg_attr(feature = "rkyv_0_8", rkyv(derive(Debug)))] +#[serde(tag = "level", rename_all = "snake_case")] +pub enum StabilityLevel { + Stable { + /// The Rust version in which this item became stable, if available. + since: Option, + }, + Unstable, +} + #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[cfg_attr(feature = "rkyv_0_8", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))] #[cfg_attr(feature = "rkyv_0_8", rkyv(derive(Debug)))] @@ -306,6 +363,7 @@ pub struct Item { /// This doesn't include: /// - `#[doc = "Doc Comment"]` or `/// Doc comment`. These are in [`Item::docs`] instead. /// - `#[deprecated]`. These are in [`Item::deprecation`] instead. +/// - `#[stable]` and `#[unstable]`. These are in [`Item::stability`] instead. pub enum Attribute { /// `#[non_exhaustive]` NonExhaustive,