Skip to content

Fix [rustdoc] Non-json time diagnostics in stdout when using --format… #144821

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

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

Conversation

cp90-pixel
Copy link

I've updated the display_times method in doctest.rs to check if JSON output is requested before printing the timing information. Here's what the change does:

Added a check for --format or --format=json in the command-line arguments using std::env::args().any()
The timing information will only be printed if:
There were merged doctests compiled (self.added_compilation_times > 0)
AND JSON format is NOT requested
This change ensures that when running with --format json, the timing information won't be printed to stdout, which would otherwise corrupt the JSON output. The timing information is still available when running in the default format.

@rustbot
Copy link
Collaborator

rustbot commented Aug 2, 2025

r? @GuillaumeGomez

rustbot has assigned @GuillaumeGomez.
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 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. labels Aug 2, 2025
Copy link
Member

@GuillaumeGomez GuillaumeGomez left a comment

Choose a reason for hiding this comment

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

Not displaying in JSON output format is not a fix. ^^'

@rustbot rustbot 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 Aug 2, 2025
@GuillaumeGomez
Copy link
Member

Related issue: #144798

The correct fix would be to display the output in the expected format, not display it only when not JSON. Also I assigned this issue to me as it might be a bit more complex than that.

@rust-log-analyzer
Copy link
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
##[endgroup]
[TIMING] core::build_steps::tool::ToolBuild { build_compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu, tool: "tidy", path: "src/tools/tidy", mode: ToolBootstrap, source_type: InTree, extra_features: [], allow_features: "", cargo_args: [], artifact_kind: Binary } -- 11.285
[TIMING] core::build_steps::tool::Tidy { compiler: Compiler { stage: 0, host: x86_64-unknown-linux-gnu, forced_compiler: false }, target: x86_64-unknown-linux-gnu } -- 0.000
fmt check
Diff in /checkout/src/librustdoc/doctest.rs:65:
         // displayed by `libtest` for standalone tests are already accurate (they include both
         // compilation and runtime).
         // Skip output if JSON format is requested to maintain valid JSON output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

4 participants