From 48438ce1ae2a369f10287b94f8fa8074f91a9cab Mon Sep 17 00:00:00 2001 From: Roc Yu Date: Wed, 12 Jan 2022 15:57:46 -0500 Subject: [PATCH] Remove intermediate `collect` --- src/librustdoc/doctest.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index ac24543929b..67d43fbf0bb 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -395,7 +395,7 @@ fn run_test( eprint!("{}", self.0); } } - let mut out_lines = str::from_utf8(&output.stderr) + let mut out = str::from_utf8(&output.stderr) .unwrap() .lines() .filter(|l| { @@ -406,15 +406,15 @@ fn run_test( true } }) - .collect::>(); + .intersperse_with(|| "\n") + .collect::(); // Add a \n to the end to properly terminate the last line, // but only if there was output to be printed - if !out_lines.is_empty() { - out_lines.push(""); + if !out.is_empty() { + out.push('\n'); } - let out = out_lines.join("\n"); let _bomb = Bomb(&out); match (output.status.success(), lang_string.compile_fail) { (true, true) => {