about summary refs log tree commit diff
diff options
context:
space:
mode:
authorThomas Etter <thomas.etter@auterion.com>2019-11-19 21:35:07 +0100
committerThomas Etter <thomas.etter@auterion.com>2019-11-19 21:44:45 +0100
commit16bf4f5e1b50773c6b4ec7b7524876440db69d1b (patch)
tree22229535794a16673ad37c38bc337a609609e92d
parent48a86e0b2cdfaba5a2a684911178d717067e4d28 (diff)
downloadrust-16bf4f5e1b50773c6b4ec7b7524876440db69d1b.tar.gz
rust-16bf4f5e1b50773c6b4ec7b7524876440db69d1b.zip
Simplify if else as suggested in PR feedback
-rw-r--r--src/libtest/test_result.rs36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/libtest/test_result.rs b/src/libtest/test_result.rs
index 5dbbd71554e..bfabe1722db 100644
--- a/src/libtest/test_result.rs
+++ b/src/libtest/test_result.rs
@@ -42,29 +42,25 @@ pub fn calc_result<'a>(
                 .map(|e| &**e)
                 .or_else(|| err.downcast_ref::<&'static str>().map(|e| *e));
 
-            if maybe_panic_str
-                .map(|e| e.contains(msg))
-                .unwrap_or(false)
-            {
+            if maybe_panic_str.map(|e| e.contains(msg)).unwrap_or(false) {
                 TestResult::TrOk
-            } else {
-                if desc.allow_fail {
-                    TestResult::TrAllowedFail
-                } else {
-                    if let Some(panic_str) = maybe_panic_str{
-                        TestResult::TrFailedMsg(
-                            format!(r#"panic did not contain expected string
+            } else if desc.allow_fail {
+                TestResult::TrAllowedFail
+            } else if let Some(panic_str) = maybe_panic_str {
+                TestResult::TrFailedMsg(format!(
+                    r#"panic did not contain expected string
       panic message: `{:?}`,
- expected substring: `{:?}`"#, panic_str, &*msg)
-                        )
-                    } else {
-                        TestResult::TrFailedMsg(
-                            format!(r#"expected panic with string value,
+ expected substring: `{:?}`"#,
+                    panic_str, msg
+                ))
+            } else {
+                TestResult::TrFailedMsg(format!(
+                    r#"expected panic with string value,
  found non-string value: `{:?}`
-     expected substring: `{:?}`"#, (**err).type_id(), &*msg)
-                        )
-                    }
-                }
+     expected substring: `{:?}`"#,
+                    (**err).type_id(),
+                    msg
+                ))
             }
         }
         (&ShouldPanic::Yes, Ok(())) => {