1
Fork 0

Make tests capture the error printed by a Result return

This commit is contained in:
David Tolnay 2022-10-07 13:45:41 -07:00
parent 43c22af267
commit 293f662ca9
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
3 changed files with 24 additions and 9 deletions

View file

@ -2200,9 +2200,7 @@ impl<T: Termination, E: fmt::Debug> Termination for Result<T, E> {
match self {
Ok(val) => val.report(),
Err(err) => {
// Ignore error if the write fails, for example because stderr is
// already closed. There is not much point panicking at this point.
let _ = writeln!(io::stderr(), "Error: {err:?}");
io::attempt_print_to_stderr(format_args_nl!("Error: {err:?}"));
ExitCode::FAILURE
}
}