about summary refs log tree commit diff
path: root/src/librustdoc
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-09-27 21:25:58 +0200
committerGitHub <noreply@github.com>2025-09-27 21:25:58 +0200
commita11a211d7cff89b9168d2dc5493f4bc0385877ab (patch)
tree28f81866049477bf38cf98ec5afafcf2230ae8b0 /src/librustdoc
parent13ac606956464f53ac2c81aa3a1ef8a39f7298d0 (diff)
parentb7e444de16d5945908657200d59af608d8c6232c (diff)
downloadrust-a11a211d7cff89b9168d2dc5493f4bc0385877ab.tar.gz
rust-a11a211d7cff89b9168d2dc5493f4bc0385877ab.zip
Rollup merge of #147032 - GuillaumeGomez:fix-doctest-compilation-time-display, r=lolbinarycat
Fix doctest compilation time display

Fixes rust-lang/rust#146960.

Small corner case that happened in case everything went fine and there was only merged doctests.

r? lolbinarycat
Diffstat (limited to 'src/librustdoc')
-rw-r--r--src/librustdoc/doctest.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs
index 95bd31729de..9499258f983 100644
--- a/src/librustdoc/doctest.rs
+++ b/src/librustdoc/doctest.rs
@@ -404,11 +404,15 @@ pub(crate) fn run_tests(
             std::mem::drop(temp_dir.take());
             times.display_times();
         });
+    } else {
+        // If the first condition branch exited successfully, `test_main_with_exit_callback` will
+        // not exit the process. So to prevent displaying the times twice, we put it behind an
+        // `else` condition.
+        times.display_times();
     }
+    // We ensure temp dir destructor is called.
+    std::mem::drop(temp_dir);
     if nb_errors != 0 {
-        // We ensure temp dir destructor is called.
-        std::mem::drop(temp_dir);
-        times.display_times();
         std::process::exit(test::ERROR_EXIT_CODE);
     }
 }