@@ -641,6 +641,10 @@ pub fn begin_panic_handler(info: &core::panic::PanicInfo<'_>) -> ! {
641641fn get ( & mut self ) ->& ( dyn Any +Send ) {
642642& self . 0
643643}
644+
645+ fn as_str ( & mut self ) ->Option < & str > {
646+ Some ( self . 0 )
647+ }
644648}
645649
646650impl fmt:: Display for StaticStrPayload {
@@ -763,15 +767,8 @@ fn rust_panic_with_hook(
763767// Don't try to format the message in this case, perhaps that is causing the
764768// recursive panics. However if the message is just a string, no user-defined
765769// code is involved in printing it, so that is risk-free.
766- let msg_str = message. and_then ( |m| m. as_str ( ) ) . map ( |m|[ m] ) ;
767- let message = msg_str. as_ref ( ) . map ( |m| fmt:: Arguments :: new_const ( m) ) ;
768- let panicinfo =PanicInfo :: internal_constructor (
769- message. as_ref ( ) ,
770- location,
771- can_unwind,
772- force_no_backtrace,
773- ) ;
774- rtprintpanic ! ( "{panicinfo}\n thread panicked while processing panic. aborting.\n " ) ;
770+ let message: & str = payload. as_str ( ) . unwrap_or_default ( ) ;
771+ rtprintpanic ! ( "panicked at {location}:\n {message}\n thread panicked while processing panic. aborting.\n " ) ;
775772}
776773 panic_count:: MustAbort :: AlwaysAbort =>{
777774// Unfortunately, this does not print a backtrace, because creating