about summary refs log tree commit diff
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2025-08-02 12:44:51 +1000
committerZalathar <Zalathar@users.noreply.github.com>2025-08-03 13:38:07 +1000
commit2ddf0ca9f5402ce6a710d35a5beb2067201ff23d (patch)
tree4e72e96bed854ff483e092d2cf8f2fba2857ee24
parent5b9564a18950db64c5aee8ba19d55a97b2e8d1cf (diff)
downloadrust-2ddf0ca9f5402ce6a710d35a5beb2067201ff23d.tar.gz
rust-2ddf0ca9f5402ce6a710d35a5beb2067201ff23d.zip
Change `ProcRes::print_info` to `format_info`
This method now returns a string instead of printing directly to
(possibly-captured) stdout.
-rw-r--r--src/tools/compiletest/src/runtest.rs9
-rw-r--r--src/tools/compiletest/src/runtest/rustdoc_json.rs2
2 files changed, 6 insertions, 5 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index ba7fcadbc2e..12a5e55e77b 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -2957,7 +2957,8 @@ pub struct ProcRes {
 }
 
 impl ProcRes {
-    pub fn print_info(&self) {
+    #[must_use]
+    pub fn format_info(&self) -> String {
         fn render(name: &str, contents: &str) -> String {
             let contents = json::extract_rendered(contents);
             let contents = contents.trim_end();
@@ -2973,20 +2974,20 @@ impl ProcRes {
             }
         }
 
-        println!(
+        format!(
             "status: {}\ncommand: {}\n{}\n{}\n",
             self.status,
             self.cmdline,
             render("stdout", &self.stdout),
             render("stderr", &self.stderr),
-        );
+        )
     }
 
     pub fn fatal(&self, err: Option<&str>, on_failure: impl FnOnce()) -> ! {
         if let Some(e) = err {
             println!("\nerror: {}", e);
         }
-        self.print_info();
+        println!("{}", self.format_info());
         on_failure();
         // Use resume_unwind instead of panic!() to prevent a panic message + backtrace from
         // compiletest, which is unnecessary noise.
diff --git a/src/tools/compiletest/src/runtest/rustdoc_json.rs b/src/tools/compiletest/src/runtest/rustdoc_json.rs
index 4f35efedfde..7c23665c390 100644
--- a/src/tools/compiletest/src/runtest/rustdoc_json.rs
+++ b/src/tools/compiletest/src/runtest/rustdoc_json.rs
@@ -31,7 +31,7 @@ impl TestCx<'_> {
         if !res.status.success() {
             self.fatal_proc_rec_with_ctx("jsondocck failed!", &res, |_| {
                 println!("Rustdoc Output:");
-                proc_res.print_info();
+                println!("{}", proc_res.format_info());
             })
         }