Skip to content

Commit 8db6a2e

Browse files
committed
Avoid some cloning
1 parent c40e47c commit 8db6a2e

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

src/lib.rs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ impl dyn TestStatus {
605605
let (cmd, output) = run_command(cmd)?;
606606

607607
let mode = comments.mode(revision)?;
608-
let cmd = check_test_result(
608+
let (cmd, output) = check_test_result(
609609
cmd,
610610
match *mode {
611611
Mode::Run { .. } => Mode::Pass,
@@ -615,16 +615,14 @@ impl dyn TestStatus {
615615
&config,
616616
revision,
617617
comments,
618-
&output,
618+
output,
619619
)?;
620620

621621
if let Mode::Run { .. } = *mode {
622622
return run_test_binary(mode, path, revision, comments, cmd, &config);
623623
}
624624

625-
run_rustfix(
626-
&output, path, comments, revision, &config, *mode, extra_args,
627-
)?;
625+
run_rustfix(output, path, comments, revision, &config, *mode, extra_args)?;
628626
Ok(TestOk::Ok)
629627
}
630628
}
@@ -758,7 +756,7 @@ fn run_test_binary(
758756
}
759757

760758
fn run_rustfix(
761-
output: &Output,
759+
output: Output,
762760
path: &Path,
763761
comments: &Comments,
764762
revision: &str,
@@ -821,8 +819,8 @@ fn run_rustfix(
821819
.map_err(|err| Errored {
822820
command: Command::new(format!("rustfix {}", path.display())),
823821
errors: vec![Error::Rustfix(err)],
824-
stderr: output.stderr.clone(),
825-
stdout: output.stdout.clone(),
822+
stderr: output.stderr,
823+
stdout: output.stdout,
826824
})?;
827825

828826
let edition = comments.edition(revision)?.into();
@@ -929,23 +927,19 @@ fn check_test_result(
929927
config: &Config,
930928
revision: &str,
931929
comments: &Comments,
932-
Output {
933-
status,
934-
stdout,
935-
stderr,
936-
}: &Output,
937-
) -> Result<Command, Errored> {
930+
output: Output,
931+
) -> Result<(Command, Output), Errored> {
938932
let mut errors = vec![];
939-
errors.extend(mode.ok(*status).err());
933+
errors.extend(mode.ok(output.status).err());
940934
// Always remove annotation comments from stderr.
941-
let diagnostics = rustc_stderr::process(path, stderr);
935+
let diagnostics = rustc_stderr::process(path, &output.stderr);
942936
check_test_output(
943937
path,
944938
&mut errors,
945939
revision,
946940
config,
947941
comments,
948-
stdout,
942+
&output.stdout,
949943
&diagnostics.rendered,
950944
);
951945
// Check error annotations in the source against output
@@ -958,13 +952,13 @@ fn check_test_result(
958952
comments,
959953
)?;
960954
if errors.is_empty() {
961-
Ok(command)
955+
Ok((command, output))
962956
} else {
963957
Err(Errored {
964958
command,
965959
errors,
966960
stderr: diagnostics.rendered,
967-
stdout: stdout.clone(),
961+
stdout: output.stdout,
968962
})
969963
}
970964
}

0 commit comments

Comments
 (0)