Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
<a name="v0.58.0"></a>
# [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)

<a name="v0.57.4"></a>
# [v0.57.4](https://github.com/rust-lang/rustdoc-types/releases/tag/v0.57.4) - 2026-06-19

Expand Down
2 changes: 1 addition & 1 deletion COMMIT.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fee82a37e9eabf8afe6db62c0177baaf63356a98
818d29d02798f5e48d28c868e4034294a7a38597
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
64 changes: 61 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -281,7 +281,10 @@ pub struct Item {
pub links: HashMap<String, Id>,
/// 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:
Expand All @@ -293,10 +296,64 @@ pub struct Item {
pub attrs: Vec<Attribute>,
/// Information about the item’s deprecation, if present.
pub deprecation: Option<Deprecation>,

/// 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<Box<Stability>>,

/// 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<String>,
},
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)))]
Expand All @@ -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,
Expand Down