Skip to content

Commit 1c420b0

Browse files
committed
improve style in catch_panic test
1 parent f3c00a4 commit 1c420b0

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

tests/run-pass/catch_panic.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,13 @@ fn test(do_panic: impl FnOnce(usize) -> !) {
7070
do_panic_counter(do_panic)
7171
})).expect_err("do_panic() did not panic!");
7272

73-
// See if we can extract panic message.
74-
match res.downcast::<String>() {
75-
Ok(s) => {
76-
eprintln!("Caught panic message (String): {}", s);
77-
}
78-
Err(res) =>
79-
if let Ok(s) = res.downcast::<&str>() {
80-
eprintln!("Caught panic message (&str): {}", s);
81-
} else {
82-
eprintln!("Failed get caught panic message.");
83-
}
73+
// See if we can extract the panic message.
74+
if let Some(s) = res.downcast_ref::<String>() {
75+
eprintln!("Caught panic message (String): {}", s);
76+
} else if let Some(s) = res.downcast_ref::<&str>() {
77+
eprintln!("Caught panic message (&str): {}", s);
78+
} else {
79+
eprintln!("Failed get caught panic message.");
8480
}
8581

8682
// Test flags.

0 commit comments

Comments
 (0)