File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments