Skip to content

rustdoc: Repersent --output-format=json coverage and ir diferently#154445

Open
aDotInTheVoid wants to merge 1 commit intorust-lang:mainfrom
aDotInTheVoid:better-enum
Open

rustdoc: Repersent --output-format=json coverage and ir diferently#154445
aDotInTheVoid wants to merge 1 commit intorust-lang:mainfrom
aDotInTheVoid:better-enum

Conversation

@aDotInTheVoid
Copy link
Copy Markdown
Member

--output-format=json does a few different things:

  • By itself, it emits a JSON representation of a crate's API ("IR JSON").
  • When used with --show-coverage, it prints the doc coverage as JSON, instead of a ascii table ("Coverage JSON").

These two cases need to be handled entirely differently. There's no overlapping code, they just are called the same way.

By making these seperate variants, we don't need to check the show_coverage variable each time we check is_json, which makes it harder to write a bug that checks for IR JSON, and accidently happens in coverage JSON too.

Also, as a driveby, improves some instability error messages, and cleans up their tests, and adds a test for the unknown output format case.

`--output-format=json` does a few different things:

- By itself, it emits a JSON representation of a crate's API ("IR
  JSON").
- When used with `--show-coverage`, it prints the doc coverage as JSON,
  instead of a ascii table ("Coverage JSON").

These two cases need to be handled entirely differently. There's no
overlapping code, they just are called the same way.

By making these seperate variants, we don't need to check the
`show_coverage` variable each time we check `is_json`, which makes it
harder to write a bug that checks for IR JSON, and accidently happens in
coverage JSON too.

Also, as a driveby, improves some instability error messages, and cleans
up their tests, and adds a test for the unknown output format case.
@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Mar 27, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 27, 2026

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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: rustdoc
  • rustdoc expanded to 9 candidates
  • Random selection from GuillaumeGomez, camelid, fmease, lolbinarycat, notriddle

@aDotInTheVoid aDotInTheVoid added the A-rustdoc-json Area: Rustdoc JSON backend label Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-make Area: port run-make Makefiles to rmake.rs A-rustdoc-json Area: Rustdoc JSON backend S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants