Skip to content

feat: Add --output-format=json to cargo doc as an unstable option#17025

Merged
weihanglo merged 1 commit into
rust-lang:masterfrom
LukeMathWalker:cargo-doc-fix
May 27, 2026
Merged

feat: Add --output-format=json to cargo doc as an unstable option#17025
weihanglo merged 1 commit into
rust-lang:masterfrom
LukeMathWalker:cargo-doc-fix

Conversation

@LukeMathWalker

@LukeMathWalker LukeMathWalker commented May 23, 2026

Copy link
Copy Markdown
Contributor

What does this PR try to resolve?

In #13283, the issue of naming conflict between doc artefacts was raised as a reason to wait before adding --output-format support to cargo doc.
Given the changes in #16773, I argue we shouldn't treat that oustanding design question as a blocker: since JSON doc output is now locked in to use the new build directory layout, we get benefits from first-class support in cargo doc even if the conflicts in the target directory remain unresolved.
Namely, it becomes possible to compute the JSON docs for the whole workspace at once and then retrieve the artefacts directly from the build directory. This would significantly speed up tools like cheadergen when launched on workspaces that inevitably have multiple versions of the same crate in their dependency tree.

How to test and review this PR?

I followed the same testing approach used in #16773 to ease review. Happy to add more test cases if we deem they are necessary.

@rustbot rustbot added A-cli Area: Command-line interface, option parsing, etc. Command-doc labels May 23, 2026
@weihanglo

Copy link
Copy Markdown
Member

cc #13283

@LukeMathWalker

LukeMathWalker commented May 26, 2026

Copy link
Copy Markdown
Contributor Author

cc @aDotInTheVoid for visibility.

@LukeMathWalker LukeMathWalker marked this pull request as ready for review May 26, 2026 07:35
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 26, 2026
@rustbot

rustbot commented May 26, 2026

Copy link
Copy Markdown
Collaborator

r? @weihanglo

rustbot has assigned @weihanglo.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

@weihanglo weihanglo May 27, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems good to me.

Namely, it becomes possible to compute the JSON docs for the whole workspace at once and then retrieve the artefacts directly from the build directory.

I don't understand this. build directory layout is private, and I don't know there is really a way to retrieve artifacts from there. That said, this doesn't block this from merging. Thanks for the PR!

View changes since the review

@weihanglo weihanglo added this pull request to the merge queue May 27, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks May 27, 2026
@weihanglo weihanglo added this pull request to the merge queue May 27, 2026
Merged via the queue into rust-lang:master with commit 5d9c85d May 27, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 27, 2026
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jun 3, 2026
Update cargo submodule

14 commits in fbb61be30e5f9ac3a6ad58e56a5c0f5db2d2b3ef..0b1123a48825309b697312b44fdb64b3df00c958
2026-05-26 15:08:03 +0000 to 2026-06-01 21:20:28 +0000
- chore(deps): update rust crate git2 to 0.21.0 (rust-lang/cargo#17060)
- chore(deps): update compatible (rust-lang/cargo#17057)
- fix(util): constant type for Redox OS  (rust-lang/cargo#17064)
- chore(deps): update crate-ci/typos action to v1.47.0 (rust-lang/cargo#17059)
- chore(deps): update embarkstudios/cargo-deny-action action to v2.0.20 (rust-lang/cargo#17058)
- chore(deps): update cargo-semver-checks to v0.48.0 (rust-lang/cargo#17054)
- chore: bump to 0.99.0; update changelog (rust-lang/cargo#17049)
- Bump cargo-util-schemas to 0.14.2 (rust-lang/cargo#17048)
- feat: Add edition for scripts anytime we mutate the manifest (rust-lang/cargo#17038)
- docs: clarify on crate removal post RFC 3660 (rust-lang/cargo#17036)
- feat: Add --output-format=json to cargo doc as an unstable option (rust-lang/cargo#17025)
- feat(diag): Add the 'cargo::default' group (rust-lang/cargo#17033)
- fix(add): Ensure erros are lower case (rust-lang/cargo#17037)
- fix(diag): Report summaries for unused_deps (rust-lang/cargo#17034)
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jun 3, 2026
Update cargo submodule

14 commits in fbb61be30e5f9ac3a6ad58e56a5c0f5db2d2b3ef..0b1123a48825309b697312b44fdb64b3df00c958
2026-05-26 15:08:03 +0000 to 2026-06-01 21:20:28 +0000
- chore(deps): update rust crate git2 to 0.21.0 (rust-lang/cargo#17060)
- chore(deps): update compatible (rust-lang/cargo#17057)
- fix(util): constant type for Redox OS  (rust-lang/cargo#17064)
- chore(deps): update crate-ci/typos action to v1.47.0 (rust-lang/cargo#17059)
- chore(deps): update embarkstudios/cargo-deny-action action to v2.0.20 (rust-lang/cargo#17058)
- chore(deps): update cargo-semver-checks to v0.48.0 (rust-lang/cargo#17054)
- chore: bump to 0.99.0; update changelog (rust-lang/cargo#17049)
- Bump cargo-util-schemas to 0.14.2 (rust-lang/cargo#17048)
- feat: Add edition for scripts anytime we mutate the manifest (rust-lang/cargo#17038)
- docs: clarify on crate removal post RFC 3660 (rust-lang/cargo#17036)
- feat: Add --output-format=json to cargo doc as an unstable option (rust-lang/cargo#17025)
- feat(diag): Add the 'cargo::default' group (rust-lang/cargo#17033)
- fix(add): Ensure erros are lower case (rust-lang/cargo#17037)
- fix(diag): Report summaries for unused_deps (rust-lang/cargo#17034)
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jun 3, 2026
Update cargo submodule

14 commits in fbb61be30e5f9ac3a6ad58e56a5c0f5db2d2b3ef..0b1123a48825309b697312b44fdb64b3df00c958
2026-05-26 15:08:03 +0000 to 2026-06-01 21:20:28 +0000
- chore(deps): update rust crate git2 to 0.21.0 (rust-lang/cargo#17060)
- chore(deps): update compatible (rust-lang/cargo#17057)
- fix(util): constant type for Redox OS  (rust-lang/cargo#17064)
- chore(deps): update crate-ci/typos action to v1.47.0 (rust-lang/cargo#17059)
- chore(deps): update embarkstudios/cargo-deny-action action to v2.0.20 (rust-lang/cargo#17058)
- chore(deps): update cargo-semver-checks to v0.48.0 (rust-lang/cargo#17054)
- chore: bump to 0.99.0; update changelog (rust-lang/cargo#17049)
- Bump cargo-util-schemas to 0.14.2 (rust-lang/cargo#17048)
- feat: Add edition for scripts anytime we mutate the manifest (rust-lang/cargo#17038)
- docs: clarify on crate removal post RFC 3660 (rust-lang/cargo#17036)
- feat: Add --output-format=json to cargo doc as an unstable option (rust-lang/cargo#17025)
- feat(diag): Add the 'cargo::default' group (rust-lang/cargo#17033)
- fix(add): Ensure erros are lower case (rust-lang/cargo#17037)
- fix(diag): Report summaries for unused_deps (rust-lang/cargo#17034)
@rustbot rustbot added this to the 1.98.0 milestone Jun 3, 2026
pull Bot pushed a commit to xtqqczze/rust-lang-rustc-dev-guide that referenced this pull request Jun 4, 2026
Update cargo submodule

14 commits in fbb61be30e5f9ac3a6ad58e56a5c0f5db2d2b3ef..0b1123a48825309b697312b44fdb64b3df00c958
2026-05-26 15:08:03 +0000 to 2026-06-01 21:20:28 +0000
- chore(deps): update rust crate git2 to 0.21.0 (rust-lang/cargo#17060)
- chore(deps): update compatible (rust-lang/cargo#17057)
- fix(util): constant type for Redox OS  (rust-lang/cargo#17064)
- chore(deps): update crate-ci/typos action to v1.47.0 (rust-lang/cargo#17059)
- chore(deps): update embarkstudios/cargo-deny-action action to v2.0.20 (rust-lang/cargo#17058)
- chore(deps): update cargo-semver-checks to v0.48.0 (rust-lang/cargo#17054)
- chore: bump to 0.99.0; update changelog (rust-lang/cargo#17049)
- Bump cargo-util-schemas to 0.14.2 (rust-lang/cargo#17048)
- feat: Add edition for scripts anytime we mutate the manifest (rust-lang/cargo#17038)
- docs: clarify on crate removal post RFC 3660 (rust-lang/cargo#17036)
- feat: Add --output-format=json to cargo doc as an unstable option (rust-lang/cargo#17025)
- feat(diag): Add the 'cargo::default' group (rust-lang/cargo#17033)
- fix(add): Ensure erros are lower case (rust-lang/cargo#17037)
- fix(diag): Report summaries for unused_deps (rust-lang/cargo#17034)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area: Command-line interface, option parsing, etc. Command-doc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants