Skip to content

Commit 75dacfa

Browse files
committed
v0.54.0
1 parent 71815f8 commit 75dacfa

File tree

4 files changed

+100
-6
lines changed

4 files changed

+100
-6
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
<a name="v0.54.0"></a>
2+
# [v0.54.0](https://github.com/rust-lang/rustdoc-types/releases/tag/v0.54.0) - 2025-07-17
3+
4+
**Breaking Change**: Change `Item::attrs` from `Vec<String>` to
5+
`Vec<Attribute>`. `Attribute` is a new enum that contains variants for different
6+
attributes, and a catch-all `Other` varient. This will mean rustdoc-json
7+
consumers won't need to parse common attributes. Changes to the stringified
8+
representation in `Attribute::Other` won't cause a new `FORMAT_VERSION`.
9+
10+
- Format Version: 54
11+
- Upstream Commit: [`078332fdc8e11f7ff8253c019085098538ec3c2a`](https://github.com/rust-lang/rust/commit/078332fdc8e11f7ff8253c019085098538ec3c2a)
12+
- Diff: [v0.53.0...v0.54.0](https://github.com/rust-lang/rustdoc-types/compare/v0.53.0...v0.54.0)
13+
114
<a name="v0.53.0"></a>
215
# [v0.53.0](https://github.com/rust-lang/rustdoc-types/releases/tag/v0.53.0) - 2025-06-23
316

COMMIT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2084831cd54eb603fec6cd85ebd9d1426b09f628
1+
078332fdc8e11f7ff8253c019085098538ec3c2a

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rustdoc-types"
3-
version = "0.53.0"
3+
version = "0.54.0"
44
edition = "2018"
55
license = "MIT OR Apache-2.0"
66
description = "Types for rustdoc's json output"

src/lib.rs

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ use serde_derive::{Deserialize, Serialize};
3636
// will instead cause conflicts. See #94591 for more. (This paragraph and the "Latest feature" line
3737
// are deliberately not in a doc comment, because they need not be in public docs.)
3838
//
39-
// Latest feature: Pretty printing of no_mangle attributes changed
40-
pub const FORMAT_VERSION: u32 = 53;
39+
// Latest feature: Structured Attributes
40+
pub const FORMAT_VERSION: u32 = 54;
4141

4242
/// The root of the emitted JSON blob.
4343
///
@@ -194,13 +194,94 @@ pub struct Item {
194194
/// - `#[repr(C)]` and other reprs also appear as themselves,
195195
/// though potentially with a different order: e.g. `repr(i8, C)` may become `repr(C, i8)`.
196196
/// Multiple repr attributes on the same item may be combined into an equivalent single attr.
197-
pub attrs: Vec<String>,
197+
pub attrs: Vec<Attribute>,
198198
/// Information about the item’s deprecation, if present.
199199
pub deprecation: Option<Deprecation>,
200200
/// The type-specific fields describing this item.
201201
pub inner: ItemEnum,
202202
}
203203

204+
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
205+
#[serde(rename_all = "snake_case")]
206+
/// An attribute, e.g. `#[repr(C)]`
207+
///
208+
/// This doesn't include:
209+
/// - `#[doc = "Doc Comment"]` or `/// Doc comment`. These are in [`Item::docs`] instead.
210+
/// - `#[deprecated]`. These are in [`Item::deprecation`] instead.
211+
pub enum Attribute {
212+
/// `#[non_exhaustive]`
213+
NonExhaustive,
214+
215+
/// `#[must_use]`
216+
MustUse { reason: Option<String> },
217+
218+
/// `#[export_name = "name"]`
219+
ExportName(String),
220+
221+
/// `#[link_section = "name"]`
222+
LinkSection(String),
223+
224+
/// `#[automatically_derived]`
225+
AutomaticallyDerived,
226+
227+
/// `#[repr]`
228+
Repr(AttributeRepr),
229+
230+
/// `#[no_mangle]`
231+
NoMangle,
232+
233+
/// #[target_feature(enable = "feature1", enable = "feature2")]
234+
TargetFeature { enable: Vec<String> },
235+
236+
/// Something else.
237+
///
238+
/// Things here are explicitly *not* covered by the [`FORMAT_VERSION`]
239+
/// constant, and may change without bumping the format version.
240+
///
241+
/// As an implementation detail, this is currently either:
242+
/// 1. A HIR debug printing, like `"#[attr = Optimize(Speed)]"`
243+
/// 2. The attribute as it appears in source form, like
244+
/// `"#[optimize(speed)]"`.
245+
Other(String),
246+
}
247+
248+
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
249+
/// The contents of a `#[repr(...)]` attribute.
250+
///
251+
/// Used in [`Attribute::Repr`].
252+
pub struct AttributeRepr {
253+
/// The representation, e.g. `#[repr(C)]`, `#[repr(transparent)]`
254+
pub kind: ReprKind,
255+
256+
/// Alignment in bytes, if explicitly specified by `#[repr(align(...)]`.
257+
pub align: Option<u64>,
258+
/// Alignment in bytes, if explicitly specified by `#[repr(packed(...)]]`.
259+
pub packed: Option<u64>,
260+
261+
/// The integer type for an enum descriminant, if explicitly specified.
262+
///
263+
/// e.g. `"i32"`, for `#[repr(C, i32)]`
264+
pub int: Option<String>,
265+
}
266+
267+
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
268+
#[serde(rename_all = "snake_case")]
269+
/// The kind of `#[repr]`.
270+
///
271+
/// See [AttributeRepr::kind]`.
272+
pub enum ReprKind {
273+
/// `#[repr(Rust)]`
274+
///
275+
/// Also the default.
276+
Rust,
277+
/// `#[repr(C)]`
278+
C,
279+
/// `#[repr(transparent)]
280+
Transparent,
281+
/// `#[repr(simd)]`
282+
Simd,
283+
}
284+
204285
/// A range of source code.
205286
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
206287
pub struct Span {
@@ -1342,7 +1423,7 @@ pub struct Static {
13421423

13431424
/// Is the static `unsafe`?
13441425
///
1345-
/// This is only true if it's in an `extern` block, and not explicity marked
1426+
/// This is only true if it's in an `extern` block, and not explicitly marked
13461427
/// as `safe`.
13471428
///
13481429
/// ```rust

0 commit comments

Comments
 (0)