Skip to content

Commit 4ce257f

Browse files
committed
Auto merge of #92361 - vacuus:doctest-run-test-out-lines, r=CraftSpider
Remove `collect` in `doctest::run_test`
2 parents 661e8be + 48438ce commit 4ce257f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/librustdoc/doctest.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ fn run_test(
399399
eprint!("{}", self.0);
400400
}
401401
}
402-
let mut out_lines = str::from_utf8(&output.stderr)
402+
let mut out = str::from_utf8(&output.stderr)
403403
.unwrap()
404404
.lines()
405405
.filter(|l| {
@@ -410,15 +410,15 @@ fn run_test(
410410
true
411411
}
412412
})
413-
.collect::<Vec<_>>();
413+
.intersperse_with(|| "\n")
414+
.collect::<String>();
414415

415416
// Add a \n to the end to properly terminate the last line,
416417
// but only if there was output to be printed
417-
if !out_lines.is_empty() {
418-
out_lines.push("");
418+
if !out.is_empty() {
419+
out.push('\n');
419420
}
420421

421-
let out = out_lines.join("\n");
422422
let _bomb = Bomb(&out);
423423
match (output.status.success(), lang_string.compile_fail) {
424424
(true, true) => {

0 commit comments

Comments
 (0)