Skip to content

WIP: rustdoc-json: Structured attributes #142936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aDotInTheVoid
Copy link
Member

@aDotInTheVoid aDotInTheVoid commented Jun 23, 2025

Implements #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. CC @obi1kenobi
  2. For rustc co, the output of HIR pretty printing is no longer a versioned thing in the output. People can work on Tracking issue: Attribute refactor #131229 without needing to bump FORMAT_VERSION. CC @jdonszelmann @JonathanBrouwer.

(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).

Todo before merging:

  • Update test assertions.
  • Fix modeling of #[repr].

@rustbot
Copy link
Collaborator

rustbot commented Jun 23, 2025

r? @notriddle

rustbot has assigned @notriddle.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jun 23, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 23, 2025

rustdoc-json-types is a public (although nightly-only) API. If possible, consider changing src/librustdoc/json/conversions.rs; otherwise, make sure you bump the FORMAT_VERSION constant.

cc @CraftSpider, @aDotInTheVoid, @Enselic, @obi1kenobi

@jdonszelmann
Copy link
Contributor

Awesome alona! I'll take a proper look tomorrow <3

@aDotInTheVoid aDotInTheVoid added the A-attributes Area: Attributes (`#[…]`, `#![…]`) label Jun 23, 2025
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-1 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/automatically_derived" "--template" "/checkout/tests/rustdoc-json/attrs/automatically_derived.rs"
stdout: none
--- stderr -------------------------------
/checkout/tests/rustdoc-json/attrs/automatically_derived.rs:12, directive failed
matched to Array [String("AutomaticallyDerived")] but want Array [String("#[automatically_derived]")]
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/automatically_derived" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/automatically_derived/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/automatically_derived" "--deny" "warnings" "/checkout/tests/rustdoc-json/attrs/automatically_derived.rs" "-A" "internal_features" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none


---- [rustdoc-json] tests/rustdoc-json/attrs/export_name_2021.rs stdout ----

error: jsondocck failed!
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/export_name_2021" "--template" "/checkout/tests/rustdoc-json/attrs/export_name_2021.rs"
stdout: none
--- stderr -------------------------------
/checkout/tests/rustdoc-json/attrs/export_name_2021.rs:4, directive failed
matched to Array [Object {"ExportName": String("altered")}] but want Array [String("#[export_name = \"altered\"]")]
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/export_name_2021" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/export_name_2021/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/export_name_2021" "--deny" "warnings" "/checkout/tests/rustdoc-json/attrs/export_name_2021.rs" "-A" "internal_features" "--edition=2021" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none


---- [rustdoc-json] tests/rustdoc-json/attrs/export_name_2024.rs stdout ----

error: jsondocck failed!
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/export_name_2024" "--template" "/checkout/tests/rustdoc-json/attrs/export_name_2024.rs"
stdout: none
--- stderr -------------------------------
/checkout/tests/rustdoc-json/attrs/export_name_2024.rs:7, directive failed
matched to Array [Object {"ExportName": String("altered")}] but want Array [String("#[export_name = \"altered\"]")]
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/export_name_2024" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/export_name_2024/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/export_name_2024" "--deny" "warnings" "/checkout/tests/rustdoc-json/attrs/export_name_2024.rs" "-A" "internal_features" "--edition=2024" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none


---- [rustdoc-json] tests/rustdoc-json/attrs/must_use.rs stdout ----

error: jsondocck failed!
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/must_use" "--template" "/checkout/tests/rustdoc-json/attrs/must_use.rs"
stdout: none
--- stderr -------------------------------
/checkout/tests/rustdoc-json/attrs/must_use.rs:3, directive failed
matched to Array [Object {"MustUse": Object {"reason": Null}}] but want Array [String("#[attr = MustUse]")]
/checkout/tests/rustdoc-json/attrs/must_use.rs:7, directive failed
matched to Array [Object {"MustUse": Object {"reason": String("does nothing if you do not use it")}}] but want Array [String("#[attr = MustUse {reason: \"does nothing if you do not use it\"}]")]
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/must_use" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/must_use/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/must_use" "--deny" "warnings" "/checkout/tests/rustdoc-json/attrs/must_use.rs" "-A" "internal_features" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none


---- [rustdoc-json] tests/rustdoc-json/attrs/inline.rs stdout ----

error: jsondocck failed!
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/inline" "--template" "/checkout/tests/rustdoc-json/attrs/inline.rs"
stdout: none
--- stderr -------------------------------
/checkout/tests/rustdoc-json/attrs/inline.rs:1, directive failed
matched to Array [Object {"Other": String("#[attr = Inline(Hint)]\n")}] but want Array [String("#[attr = Inline(Hint)]")]
/checkout/tests/rustdoc-json/attrs/inline.rs:5, directive failed
matched to Array [Object {"Other": String("#[attr = Inline(Always)]\n")}] but want Array [String("#[attr = Inline(Always)]")]
/checkout/tests/rustdoc-json/attrs/inline.rs:9, directive failed
matched to Array [Object {"Other": String("#[attr = Inline(Never)]\n")}] but want Array [String("#[attr = Inline(Never)]")]
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/inline" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/inline/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/inline" "--deny" "warnings" "/checkout/tests/rustdoc-json/attrs/inline.rs" "-A" "internal_features" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none


---- [rustdoc-json] tests/rustdoc-json/attrs/no_mangle_2021.rs stdout ----

error: jsondocck failed!
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/no_mangle_2021" "--template" "/checkout/tests/rustdoc-json/attrs/no_mangle_2021.rs"
stdout: none
--- stderr -------------------------------
/checkout/tests/rustdoc-json/attrs/no_mangle_2021.rs:4, directive failed
matched to Array [String("NoMangle")] but want Array [String("#[no_mangle]")]
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/no_mangle_2021" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/no_mangle_2021/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/no_mangle_2021" "--deny" "warnings" "/checkout/tests/rustdoc-json/attrs/no_mangle_2021.rs" "-A" "internal_features" "--edition=2021" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none


---- [rustdoc-json] tests/rustdoc-json/attrs/no_mangle_2024.rs stdout ----

error: jsondocck failed!
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/no_mangle_2024" "--template" "/checkout/tests/rustdoc-json/attrs/no_mangle_2024.rs"
stdout: none
--- stderr -------------------------------
/checkout/tests/rustdoc-json/attrs/no_mangle_2024.rs:7, directive failed
matched to Array [String("NoMangle")] but want Array [String("#[no_mangle]")]
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/no_mangle_2024" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/no_mangle_2024/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/no_mangle_2024" "--deny" "warnings" "/checkout/tests/rustdoc-json/attrs/no_mangle_2024.rs" "-A" "internal_features" "--edition=2024" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none


---- [rustdoc-json] tests/rustdoc-json/attrs/non_exhaustive.rs stdout ----

error: jsondocck failed!
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/non_exhaustive" "--template" "/checkout/tests/rustdoc-json/attrs/non_exhaustive.rs"
stdout: none
--- stderr -------------------------------
/checkout/tests/rustdoc-json/attrs/non_exhaustive.rs:3, directive failed
matched to Array [String("NonExhaustive")] but want Array [String("#[non_exhaustive]")]
/checkout/tests/rustdoc-json/attrs/non_exhaustive.rs:10, directive failed
matched to Array [String("NonExhaustive")] but want Array [String("#[non_exhaustive]")]
/checkout/tests/rustdoc-json/attrs/non_exhaustive.rs:15, directive failed
matched to Array [String("NonExhaustive")] but want Array [String("#[non_exhaustive]")]
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/non_exhaustive" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/non_exhaustive/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/non_exhaustive" "--deny" "warnings" "/checkout/tests/rustdoc-json/attrs/non_exhaustive.rs" "-A" "internal_features" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none


---- [rustdoc-json] tests/rustdoc-json/attrs/repr_align.rs stdout ----

error: jsondocck failed!
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_align" "--template" "/checkout/tests/rustdoc-json/attrs/repr_align.rs"
stdout: none
--- stderr -------------------------------
/checkout/tests/rustdoc-json/attrs/repr_align.rs:3, directive failed
matched to Array [Object {"Repr": String("Rust")}] but want Array [String("#[repr(align(4))]")]
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_align" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_align/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_align" "--deny" "warnings" "/checkout/tests/rustdoc-json/attrs/repr_align.rs" "-A" "internal_features" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none


---- [rustdoc-json] tests/rustdoc-json/attrs/repr_c.rs stdout ----

error: jsondocck failed!
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_c" "--template" "/checkout/tests/rustdoc-json/attrs/repr_c.rs"
stdout: none
--- stderr -------------------------------
/checkout/tests/rustdoc-json/attrs/repr_c.rs:3, directive failed
matched to Array [Object {"Repr": String("C")}] but want Array [String("#[repr(C)]")]
/checkout/tests/rustdoc-json/attrs/repr_c.rs:7, directive failed
matched to Array [Object {"Repr": String("C")}] but want Array [String("#[repr(C)]")]
/checkout/tests/rustdoc-json/attrs/repr_c.rs:13, directive failed
matched to Array [Object {"Repr": String("C")}] but want Array [String("#[repr(C)]")]
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_c" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_c/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_c" "--deny" "warnings" "/checkout/tests/rustdoc-json/attrs/repr_c.rs" "-A" "internal_features" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none


---- [rustdoc-json] tests/rustdoc-json/attrs/repr_int_enum.rs stdout ----

error: jsondocck failed!
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_int_enum" "--template" "/checkout/tests/rustdoc-json/attrs/repr_int_enum.rs"
stdout: none
--- stderr -------------------------------
/checkout/tests/rustdoc-json/attrs/repr_int_enum.rs:3, directive failed
matched to Array [Object {"Repr": String("Rust")}] but want Array [String("#[repr(i8)]")]
/checkout/tests/rustdoc-json/attrs/repr_int_enum.rs:9, directive failed
matched to Array [Object {"Repr": String("Rust")}] but want Array [String("#[repr(i32)]")]
/checkout/tests/rustdoc-json/attrs/repr_int_enum.rs:15, directive failed
matched to Array [Object {"Repr": String("Rust")}] but want Array [String("#[repr(usize)]")]
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_int_enum" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_int_enum/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_int_enum" "--deny" "warnings" "/checkout/tests/rustdoc-json/attrs/repr_int_enum.rs" "-A" "internal_features" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none


---- [rustdoc-json] tests/rustdoc-json/attrs/repr_combination.rs stdout ----

error: jsondocck failed!
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_combination" "--template" "/checkout/tests/rustdoc-json/attrs/repr_combination.rs"
stdout: none
--- stderr -------------------------------
/checkout/tests/rustdoc-json/attrs/repr_combination.rs:6, directive failed
matched to Array [Object {"Repr": String("C")}] but want Array [String("#[repr(C, i8)]")]
/checkout/tests/rustdoc-json/attrs/repr_combination.rs:12, directive failed
matched to Array [Object {"Repr": String("C")}] but want Array [String("#[repr(C, i16)]")]
/checkout/tests/rustdoc-json/attrs/repr_combination.rs:19, directive failed
matched to Array [Object {"Repr": String("C")}] but want Array [String("#[repr(C, usize)]")]
/checkout/tests/rustdoc-json/attrs/repr_combination.rs:25, directive failed
matched to Array [Object {"Repr": String("C")}] but want Array [String("#[repr(C, packed(1))]")]
/checkout/tests/rustdoc-json/attrs/repr_combination.rs:32, directive failed
matched to Array [Object {"Repr": String("C")}] but want Array [String("#[repr(C, packed(2))]")]
/checkout/tests/rustdoc-json/attrs/repr_combination.rs:40, directive failed
matched to Array [Object {"Repr": String("C")}] but want Array [String("#[repr(C, packed(2))]")]
/checkout/tests/rustdoc-json/attrs/repr_combination.rs:47, directive failed
matched to Array [Object {"Repr": String("C")}] but want Array [String("#[repr(C, align(16))]")]
/checkout/tests/rustdoc-json/attrs/repr_combination.rs:54, directive failed
matched to Array [Object {"Repr": String("C")}] but want Array [String("#[repr(C, align(2))]")]
/checkout/tests/rustdoc-json/attrs/repr_combination.rs:62, directive failed
matched to Array [Object {"Repr": String("C")}] but want Array [String("#[repr(C, align(2))]")]
/checkout/tests/rustdoc-json/attrs/repr_combination.rs:69, directive failed
matched to Array [Object {"Repr": String("C")}] but want Array [String("#[repr(C, align(16), isize)]")]
/checkout/tests/rustdoc-json/attrs/repr_combination.rs:75, directive failed
matched to Array [Object {"Repr": String("C")}] but want Array [String("#[repr(C, align(16), isize)]")]
/checkout/tests/rustdoc-json/attrs/repr_combination.rs:81, directive failed
matched to Array [Object {"Repr": String("Transparent")}] but want Array [String("#[repr(transparent)]")]
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_combination" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_combination/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_combination" "--deny" "warnings" "/checkout/tests/rustdoc-json/attrs/repr_combination.rs" "-A" "internal_features" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none


---- [rustdoc-json] tests/rustdoc-json/attrs/repr_packed.rs stdout ----

error: jsondocck failed!
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_packed" "--template" "/checkout/tests/rustdoc-json/attrs/repr_packed.rs"
stdout: none
--- stderr -------------------------------
/checkout/tests/rustdoc-json/attrs/repr_packed.rs:6, directive failed
matched to Array [Object {"Repr": String("Rust")}] but want Array [String("#[repr(packed(1))]")]
/checkout/tests/rustdoc-json/attrs/repr_packed.rs:13, directive failed
matched to Array [Object {"Repr": String("Rust")}] but want Array [String("#[repr(packed(4))]")]
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_packed" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_packed/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/attrs/repr_packed" "--deny" "warnings" "/checkout/tests/rustdoc-json/attrs/repr_packed.rs" "-A" "internal_features" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none


---- [rustdoc-json] tests/rustdoc-json/enums/discriminant/tuple.rs stdout ----

error: jsondocck failed!
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/enums/discriminant/tuple" "--template" "/checkout/tests/rustdoc-json/enums/discriminant/tuple.rs"
stdout: none
--- stderr -------------------------------
/checkout/tests/rustdoc-json/enums/discriminant/tuple.rs:2, directive failed
matched to Array [Object {"Repr": String("Rust")}] but want Array [String("#[repr(u32)]")]
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/enums/discriminant/tuple" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/enums/discriminant/tuple/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/enums/discriminant/tuple" "--deny" "warnings" "/checkout/tests/rustdoc-json/enums/discriminant/tuple.rs" "-A" "internal_features" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none


---- [rustdoc-json] tests/rustdoc-json/enums/discriminant/struct.rs stdout ----

error: jsondocck failed!
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/enums/discriminant/struct" "--template" "/checkout/tests/rustdoc-json/enums/discriminant/struct.rs"
stdout: none
--- stderr -------------------------------
/checkout/tests/rustdoc-json/enums/discriminant/struct.rs:2, directive failed
matched to Array [Object {"Repr": String("Rust")}] but want Array [String("#[repr(i32)]")]
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/enums/discriminant/struct" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/enums/discriminant/struct/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/enums/discriminant/struct" "--deny" "warnings" "/checkout/tests/rustdoc-json/enums/discriminant/struct.rs" "-A" "internal_features" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none


---- [rustdoc-json] tests/rustdoc-json/keyword_private.rs stdout ----

error: jsondocck failed!
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/jsondocck" "--doc-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/keyword_private" "--template" "/checkout/tests/rustdoc-json/keyword_private.rs"
stdout: none
--- stderr -------------------------------
/checkout/tests/rustdoc-json/keyword_private.rs:8, directive failed
matched to Array [Object {"Other": String("#[doc(keyword = \"match\")]\n")}] but want Array [String("#[doc(keyword = \"match\")]")]
/checkout/tests/rustdoc-json/keyword_private.rs:16, directive failed
matched to Array [Object {"Other": String("#[doc(keyword = \"break\")]\n")}] but want Array [String("#[doc(keyword = \"break\")]")]
------------------------------------------

Rustdoc Output:
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/keyword_private" && env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/lib/rustlib/aarch64-unknown-linux-gnu/lib" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/keyword_private/auxiliary" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-json/keyword_private" "--deny" "warnings" "/checkout/tests/rustdoc-json/keyword_private.rs" "-A" "internal_features" "--document-private-items" "--output-format" "json" "-Zunstable-options"
stdout: none
stderr: none



Copy link
Member

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this!

In the near term cargo-semver-checks will have to internally re-stringify the attributes just for code compatibility with prior rustdoc JSON versions. But I look forward to the day when I can rip all that out and enjoy the structured form instead!

///
/// This doesn't include:
/// - `#[doc = "Doc Comment"]` or `/// Doc comment`. These are in [`Item::docs`] instead.
/// - `#[depricate]`. These are in [`Item::deprecation`] instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// - `#[depricate]`. These are in [`Item::deprecation`] instead.
/// - `#[deprecated]`. These are in [`Item::deprecation`] instead.

/// constant, and may change without bumping the format version. If you rely
/// on an attibute here, please open an issue about adding a new variant for
/// that attr.
Other(String),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would love to break out #[target_feature] out of Other as well, since the upcoming cargo-semver-checks version is going to lint it.

Comment on lines +223 to +224
/// `#[repr]`
Repr(AttributeRepr),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting for myself later that we'll need to also represent cases like #[repr(i8)] on enums, and #[repr(packed(N))] / #[repr(align(N))].

I saw the // FIXME: This is wildly insufficient comment already so I know it's already on your radar too. I just wanted a reminder to have another look at this before it merges.

@bors
Copy link
Collaborator

bors commented Jun 24, 2025

☔ The latest upstream changes (presumably #142929) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants