diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index ea821a1d9392c..e90058af69a58 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -332,12 +332,14 @@ pub fn test_main_static(tests: &[&TestDescAndFn]) { /// and checks for a `0` result. pub fn assert_test_result(result: T) { let code = result.report(); - assert_eq!( - code, 0, - "the test returned a termination value with a non-zero status code ({}) \ - which indicates a failure", - code - ); + if code != 0 { + panic!( + "the test returned a termination value with a non-zero status code ({}) \ + which indicates a failure (this most likely means your test returned \ + an `Err(_)` value)", + code, + ); + } } #[derive(Copy, Clone, Debug)]