rust/tests/rustdoc-json/attrs/repr_packed.rs
Alona Enraght-Moony 078332fdc8 rustdoc-json: Structured attributes
Implements https://www.github.com/rust-lang/rust/issues/141358.

This has 2 primary benefits:

1. For rustdoc-json consumers, they no longer need to parse strings of
   attributes, but it's there in a structured and normalized way.
2. For rustc contributors, the output of HIR pretty printing is no
   longer a versioned thing in the output. People can work on
   https://github.com/rust-lang/rust/issues/131229 without needing to
   bump `FORMAT_VERSION`.

(Over time, as the attribute refractor continues, I expect we'll add new
things to `rustdoc_json_types::Attribute`. But this can be done
separately to the rustc changes).
2025-07-15 16:52:41 +00:00

21 lines
530 B
Rust

#![no_std]
// Note the normalization:
// `#[repr(packed)]` in source becomes `{"repr": {"packed": 1, ...}}` in rustdoc JSON.
//
//@ is "$.index[?(@.name=='Packed')].attrs[*].repr.packed" 1
//@ is "$.index[?(@.name=='Packed')].attrs[*].repr.kind" '"rust"'
#[repr(packed)]
pub struct Packed {
a: i8,
b: i64,
}
//@ is "$.index[?(@.name=='PackedAligned')].attrs[*].repr.packed" 4
//@ is "$.index[?(@.name=='PackedAligned')].attrs[*].repr.kind" '"rust"'
#[repr(packed(4))]
pub struct PackedAligned {
a: i8,
b: i64,
}