From f5b316a06429ed35384bd27850d276bfd49b002d Mon Sep 17 00:00:00 2001 From: Fractiplex Date: Sat, 2 Aug 2025 09:19:14 -0400 Subject: [PATCH] Fix [rustdoc] Non-json time diagnostics in stdout when using --format json --- src/librustdoc/doctest.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 35ace6566381b..1c97f54779628 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -64,7 +64,8 @@ impl MergedDoctestTimes { // If no merged doctest was compiled, then there is nothing to display since the numbers // displayed by `libtest` for standalone tests are already accurate (they include both // compilation and runtime). - if self.added_compilation_times > 0 { + // Skip output if JSON format is requested to maintain valid JSON output. + if self.added_compilation_times > 0 && !std::env::args().any(|arg| arg == "--format" || arg == "--format=json") { println!("{self}"); } }