Skip to content

[rustdoc] Correctly handle output options with --show-coverage#159411

Open
GuillaumeGomez wants to merge 7 commits into
rust-lang:mainfrom
GuillaumeGomez:show-coverage
Open

[rustdoc] Correctly handle output options with --show-coverage#159411
GuillaumeGomez wants to merge 7 commits into
rust-lang:mainfrom
GuillaumeGomez:show-coverage

Conversation

@GuillaumeGomez

@GuillaumeGomez GuillaumeGomez commented Jul 16, 2026

Copy link
Copy Markdown
Member

View all comments

Fixes #158929.

The -o option was ignored with --show-coverage. This PR takes it into account and makes it closer to how these options are handled in the rest of rustdoc.

Considering calculate_doc_coverage was never really a pass and that I needed RenderOptions (for the -o option), I moved it out of passes.

r? @camelid

@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 Jul 16, 2026
@rustbot

rustbot commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

camelid is currently at their maximum review capacity.
They may take a while to respond.

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

Ah, maybe @Urgau then?

r? @Urgau

@rustbot rustbot assigned Urgau and unassigned camelid Jul 16, 2026
@rust-log-analyzer

This comment has been minimized.

@Urgau

Urgau commented Jul 16, 2026

Copy link
Copy Markdown
Member

I haven't looked at the implementation, but it seems a bit weird to me to have an flag called --show-coverage that doesn't show anything when used with -o. Are we worried about confusing users?

#158929 suggests updating the documentation instead.
cc @aDotInTheVoid (in case you have an opinion)

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

I haven't looked at the implementation, but it seems a bit weird to me to have an flag called --show-coverage that doesn't show anything when used with -o. Are we worried about confusing users?

#158929 suggests updating the documentation instead. cc @aDotInTheVoid (in case you have an opinion)

If you want to generate the output in a file, that seems kinda logical to not have output on stdout.

@rust-log-analyzer

This comment has been minimized.

@Urgau

Urgau commented Jul 17, 2026

Copy link
Copy Markdown
Member

If you want to generate the output in a file, that seems kinda logical to not have output on stdout.

100% agree, but the CLI option is called --show-..., that implies (at least to me) -o - (i.e. the current behavior). Maybe we should have --coverage?

Is there a way to know if some users are currently relying on the current behavior? (since this is a breaking change)

@Urgau Urgau added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 17, 2026
@GuillaumeGomez

Copy link
Copy Markdown
Member Author

docs.rs. We could rename the option, I don't mind. But something like --doc-coverage seems better than just coverage, no?

@Urgau

Urgau commented Jul 20, 2026

Copy link
Copy Markdown
Member

Yeah, --doc-coverage seems fine. I'm mostly worried about the breaking change to --show-coverage, so if -o is respected only for this new option, that seems fine to me.

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

It's a nightly only option, so breaking changes are fine. Although in this case, as long as you don't use -o, there is no change.

@Urgau

Urgau commented Jul 21, 2026

Copy link
Copy Markdown
Member

Oh! I thought --show-coverage was stable, never-mind about the breaking change then.

Though I still think renaming it to --doc-coverage would be better.

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

A follow-up and an issue about doing it would be good since we'll need an FCP. ;)

@Urgau

Urgau commented Jul 21, 2026

Copy link
Copy Markdown
Member

Created #159691 for the rename.

@Urgau

Urgau commented Jul 21, 2026

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 1010137 has been approved by Urgau

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 21, 2026
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 21, 2026
[rustdoc] Correctly handle output options with --show-coverage

Fixes rust-lang#158929.

The `-o` option was ignored with `--show-coverage`. This PR takes it into account and makes it closer to how these options are handled in the rest of rustdoc.

Considering `calculate_doc_coverage` was never really a pass and that I needed `RenderOptions` (for the `-o` option), I moved it out of passes.

r? @camelid
rust-bors Bot pushed a commit that referenced this pull request Jul 25, 2026
Rollup of 16 pull requests

Successful merges:

 - #138618 (Support using const pointers in asm `const` operand)
 - #157962 (Function item should not be used as const arg)
 - #158404 (trait_solver: normalize next-gen region constraints)
 - #158709 (rustdoc: warn on improperly interleaved HTML/MD)
 - #159720 (document #[global_allocator] constraints)
 - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled)
 - #159740 (reuse regular exported_non_generic_symbols logic in Miri)
 - #159780 (check `extern "custom"` function pointers)
 - #159786 (rustdoc-js: ignore editor temp files in test folder discovery)
 - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new)
 - #155388 (stepping into where-clauses during normalization may be productive)
 - #155914 (when bailing on ambiguity, don't force other results to ambig)
 - #159411 ([rustdoc] Correctly handle output options with --show-coverage)
 - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`)
 - #159809 (Avoid `#[target_features]`)
 - #159826 (Remove redundant `#[rustc_paren_sugar]` feature gate)
@jhpratt

jhpratt commented Jul 25, 2026

Copy link
Copy Markdown
Member

@bors r- #159876 (comment)

---- [run-make] tests\run-make\rustdoc-show-coverage stdout ----

error: rmake recipe failed to complete
status: exit code: 101
command: "D:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\test\\run-make\\rustdoc-show-coverage\\rmake.exe"
stdout: none
--- stderr -------------------------------
"D:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage2\\bin\\rustdoc.exe" "foo.rs" "-Zunstable-options" "--show-coverage" "--target=x86_64-pc-windows-msvc"
output status: `exit code: 0`
=== STDOUT ===
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| foo.rs                              |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+



=== STDERR ===



"D:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage2\\bin\\rustdoc.exe" "foo.rs" "-Zunstable-options" "--show-coverage" "-o" "-" "--target=x86_64-pc-windows-msvc"
output status: `exit code: 0`
=== STDOUT ===
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| foo.rs                              |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+



=== STDERR ===



"D:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage2\\bin\\rustdoc.exe" "foo.rs" "-Zunstable-options" "--show-coverage" "--output-format=json" "--target=x86_64-pc-windows-msvc"
output status: `exit code: 0`
=== STDOUT ===
{"foo.rs":{"total":3,"with_docs":0,"total_examples":2,"with_examples":0}}



=== STDERR ===



"D:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\stage2\\bin\\rustdoc.exe" "foo.rs" "-Zunstable-options" "--show-coverage" "--output-format=json" "-o" "-" "--target=x86_64-pc-windows-msvc"
output status: `exit code: 0`
=== STDOUT ===
{"foo.rs":{"total":3,"with_docs":0,"total_examples":2,"with_examples":0}}



=== STDERR ===

---




thread 'main' (1728) panicked at D:\a\rust\rust\tests\run-make\rustdoc-show-coverage\rmake.rs:40:5:
assertion `left == right` failed: Expected "Generated output into \"doc/foo.txt\"\n", got "Generated output into \"doc\\\\foo.txt\"\n"
  left: "Generated output into \"doc\\\\foo.txt\"\n"
 right: "Generated output into \"doc/foo.txt\"\n"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
------------------------------------------

---- [run-make] tests\run-make\rustdoc-show-coverage stdout end ----

---
Currently active steps:
test::RunMake { test_compiler: Compiler { stage: 2, host: x86_64-pc-windows-msvc, forced_compiler: false }, target: x86_64-pc-windows-msvc } at src\bootstrap\src\core\build_steps\test.rs:1959
test::Compiletest { test_compiler: Compiler { stage: 2, host: x86_64-pc-windows-msvc, forced_compiler: false }, target: x86_64-pc-windows-msvc, mode: run-make, suite: "run-make", path: "tests/run-make", compare_mode: None } at src\bootstrap\src\core\build_steps\test.rs:1959
Build completed unsuccessfully in 1:59:22
make: *** [Makefile:115: ci-msvc-py] Error 1
  local time: Sat Jul 25 03:16:09 CUT 2026
  network time: Sat, 25 Jul 2026 03:16:09 GMT
##[error]Process completed with exit code 2.
##[group]Run echo "disk usage:"
echo "disk usage:"

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 25, 2026
@rust-bors

rust-bors Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#159876), which was unapproved.

View changes since this unapproval

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

@bors try jobs=x86_64-msvc-1

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 25, 2026
[rustdoc] Correctly handle output options with --show-coverage


try-job: x86_64-msvc-1
@rust-bors

rust-bors Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

💔 Test for c781e35 failed: CI

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

The run is still running but not really? Well, CI bug I guess. Seems like it's working now.

@bors r=Urgau,aDotInTheVoid rollup

@rust-bors

rust-bors Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

📌 Commit e481f48 has been approved by Urgau,aDotInTheVoid

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 25, 2026
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 25, 2026
…gau,aDotInTheVoid

[rustdoc] Correctly handle output options with --show-coverage

Fixes rust-lang#158929.

The `-o` option was ignored with `--show-coverage`. This PR takes it into account and makes it closer to how these options are handled in the rest of rustdoc.

Considering `calculate_doc_coverage` was never really a pass and that I needed `RenderOptions` (for the `-o` option), I moved it out of passes.

r? @camelid
rust-bors Bot pushed a commit that referenced this pull request Jul 25, 2026
Rollup of 23 pull requests

Successful merges:

 - #159720 (document #[global_allocator] constraints)
 - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled)
 - #159738 (implement `CovariantUnsafeCell`)
 - #159740 (reuse regular exported_non_generic_symbols logic in Miri)
 - #159780 (check `extern "custom"` function pointers)
 - #159786 (rustdoc-js: ignore editor temp files in test folder discovery)
 - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new)
 - #155388 (stepping into where-clauses during normalization may be productive)
 - #155914 (when bailing on ambiguity, don't force other results to ambig)
 - #159204 (Add support to caller_location to rustc_public)
 - #159411 ([rustdoc] Correctly handle output options with --show-coverage)
 - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`)
 - #159676 (Update wasm-component-ld to 0.5.27)
 - #159730 (allow accessing the contents of UnsafeCell without going through get)
 - #159809 (Avoid `#[target_features]`)
 - #159810 (Add tuple never coercion collection regression test)
 - #159826 (Remove redundant `#[rustc_paren_sugar]` feature gate)
 - #159853 (Updated expect messages for `CString` struct and method documentation)
 - #159877 (Revert "Export `derive` at `core::derive` and `std::derive`")
 - #159878 (bootstrap: Remove obsolete option `build.compiletest-use-stage0-libtest`)
 - #159882 (Update expect messages in library/alloc/boxed.rs and library/alloc/string.rs to follow the style guide)
 - #159891 (Split multiline derives into std/rustc macros)
 - #159895 (rustc-dev-guide subtree update)
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 25, 2026
…gau,aDotInTheVoid

[rustdoc] Correctly handle output options with --show-coverage

Fixes rust-lang#158929.

The `-o` option was ignored with `--show-coverage`. This PR takes it into account and makes it closer to how these options are handled in the rest of rustdoc.

Considering `calculate_doc_coverage` was never really a pass and that I needed `RenderOptions` (for the `-o` option), I moved it out of passes.

r? @camelid
rust-bors Bot pushed a commit that referenced this pull request Jul 25, 2026
Rollup of 23 pull requests

Successful merges:

 - #159673 (bootstrap: forward -fdebug-prefix-map when using cc)
 - #159720 (document #[global_allocator] constraints)
 - #159732 (optimization: don't look for diagnostic/canonical items without rustc_attrs enabled)
 - #159738 (implement `CovariantUnsafeCell`)
 - #159740 (reuse regular exported_non_generic_symbols logic in Miri)
 - #159780 (check `extern "custom"` function pointers)
 - #159786 (rustdoc-js: ignore editor temp files in test folder discovery)
 - #159819 (std::sync::poison: disable auto_cfg on PoisonError::new)
 - #155388 (stepping into where-clauses during normalization may be productive)
 - #155914 (when bailing on ambiguity, don't force other results to ambig)
 - #159204 (Add support to caller_location to rustc_public)
 - #159411 ([rustdoc] Correctly handle output options with --show-coverage)
 - #159439 (Fix(lib/fs/win): Fall back on Win32 delete for `Dir::remove_file`)
 - #159676 (Update wasm-component-ld to 0.5.27)
 - #159730 (allow accessing the contents of UnsafeCell without going through get)
 - #159809 (Avoid `#[target_features]`)
 - #159810 (Add tuple never coercion collection regression test)
 - #159826 (Remove redundant `#[rustc_paren_sugar]` feature gate)
 - #159853 (Updated expect messages for `CString` struct and method documentation)
 - #159878 (bootstrap: Remove obsolete option `build.compiletest-use-stage0-libtest`)
 - #159882 (Update expect messages in library/alloc/boxed.rs and library/alloc/string.rs to follow the style guide)
 - #159891 (Split multiline derives into std/rustc macros)
 - #159895 (rustc-dev-guide subtree update)
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

💔 I suspect this PR failed tests as part of a rollup
@bors r-

After fixing the problem, consider running a try job for the failed job before re-approving.

Link to failure: #159905 (comment)

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 25, 2026
@rust-bors

rust-bors Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#159905), which was unapproved.

View changes since this unapproval

@camelid

camelid commented Jul 25, 2026

Copy link
Copy Markdown
Member
 failures:
  
  ---- [run-make] tests\run-make\rustdoc-show-coverage stdout ----
  
  error: rmake recipe failed to complete
  status: exit code: 101
  command: "C:\\a\\rust\\rust\\build\\aarch64-pc-windows-msvc\\test\\run-make\\rustdoc-show-coverage\\rmake.exe"
  stdout: none
  --- stderr -------------------------------
  "C:\\a\\rust\\rust\\build\\aarch64-pc-windows-msvc\\stage2\\bin\\rustdoc.exe" "foo.rs" "-Zunstable-options" "--show-coverage" "--target=aarch64-pc-windows-msvc"
  output status: `exit code: 0`
  === STDOUT ===
  +-------------------------------------+------------+------------+------------+------------+
  | File                                | Documented | Percentage |   Examples | Percentage |
  +-------------------------------------+------------+------------+------------+------------+
  | foo.rs                              |          0 |       0.0% |          0 |       0.0% |
  +-------------------------------------+------------+------------+------------+------------+
  | Total                               |          0 |       0.0% |          0 |       0.0% |
  +-------------------------------------+------------+------------+------------+------------+
  
  
  
  === STDERR ===
  
  
  
  "C:\\a\\rust\\rust\\build\\aarch64-pc-windows-msvc\\stage2\\bin\\rustdoc.exe" "foo.rs" "-Zunstable-options" "--show-coverage" "-o" "-" "--target=aarch64-pc-windows-msvc"
  output status: `exit code: 0`
  === STDOUT ===
  +-------------------------------------+------------+------------+------------+------------+
  | File                                | Documented | Percentage |   Examples | Percentage |
  +-------------------------------------+------------+------------+------------+------------+
  | foo.rs                              |          0 |       0.0% |          0 |       0.0% |
  +-------------------------------------+------------+------------+------------+------------+
  | Total                               |          0 |       0.0% |          0 |       0.0% |
  +-------------------------------------+------------+------------+------------+------------+
  
  
  
  === STDERR ===
  
  
  
  "C:\\a\\rust\\rust\\build\\aarch64-pc-windows-msvc\\stage2\\bin\\rustdoc.exe" "foo.rs" "-Zunstable-options" "--show-coverage" "--output-format=json" "--target=aarch64-pc-windows-msvc"
  output status: `exit code: 0`
  === STDOUT ===
  {"foo.rs":{"total":3,"with_docs":0,"total_examples":2,"with_examples":0}}
  
  
  
  === STDERR ===
  
  
  
  "C:\\a\\rust\\rust\\build\\aarch64-pc-windows-msvc\\stage2\\bin\\rustdoc.exe" "foo.rs" "-Zunstable-options" "--show-coverage" "--output-format=json" "-o" "-" "--target=aarch64-pc-windows-msvc"
  output status: `exit code: 0`
  === STDOUT ===
  {"foo.rs":{"total":3,"with_docs":0,"total_examples":2,"with_examples":0}}
  
  
  
  === STDERR ===
  
  
  
  "C:\\a\\rust\\rust\\build\\aarch64-pc-windows-msvc\\stage2\\bin\\rustdoc.exe" "foo.rs" "-Zunstable-options" "--show-coverage" "-o" "doc" "--target=aarch64-pc-windows-msvc"
  output status: `exit code: 0`
  === STDOUT ===
  Generated output into "doc\\foo.txt"
  
  
  
  === STDERR ===
  
  
  
  assert_contains_regex:
  === HAYSTACK ===
  Generated output into "doc\\foo.txt"
  
  === NEEDLE ===
  Generated output into "doc[/\\]foo.txt"
  
  
  thread 'main' (9516) panicked at C:\a\rust\rust\tests\run-make\rustdoc-show-coverage\rmake.rs:40:5:
  regex was not found in haystack
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  ------------------------------------------
  
  ---- [run-make] tests\run-make\rustdoc-show-coverage stdout end ----
  
  failures:
      [run-make] tests\run-make\rustdoc-show-coverage

@GuillaumeGomez

Copy link
Copy Markdown
Member Author

@bors try jobs=aarch64-msvc-1

@rust-bors

rust-bors Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

⌛ Trying commit 2762f10 with merge 49bbeb7

To cancel the try build, run the command @bors try cancel.

Workflow: https://github.com/rust-lang/rust/actions/runs/30174756963

rust-bors Bot pushed a commit that referenced this pull request Jul 25, 2026
[rustdoc] Correctly handle output options with --show-coverage


try-job: aarch64-msvc-1
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 S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

rustdoc: --show-coverage --output-format=json doesn't respect -o, but the docs suggest it will.

8 participants