mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-02 10:18:25 +00:00

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).
14 lines
773 B
Rust
14 lines
773 B
Rust
#[repr(i32)]
|
|
//@ is "$.index[?(@.name=='Foo')].attrs[*].repr.int" '"i32"'
|
|
pub enum Foo {
|
|
//@ is "$.index[?(@.name=='Struct')].inner.variant.discriminant" null
|
|
//@ count "$.index[?(@.name=='Struct')].inner.variant.kind.struct.fields[*]" 0
|
|
Struct {},
|
|
//@ is "$.index[?(@.name=='StructWithDiscr')].inner.variant.discriminant" '{"expr": "42", "value": "42"}'
|
|
//@ count "$.index[?(@.name=='StructWithDiscr')].inner.variant.kind.struct.fields[*]" 1
|
|
StructWithDiscr { x: i32 } = 42,
|
|
//@ is "$.index[?(@.name=='StructWithHexDiscr')].inner.variant.discriminant" '{"expr": "0x42", "value": "66"}'
|
|
//@ count "$.index[?(@.name=='StructWithHexDiscr')].inner.variant.kind.struct.fields[*]" 2
|
|
StructWithHexDiscr { x: i32, y: bool } = 0x42,
|
|
}
|