File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 259259#![ feature( exhaustive_patterns) ]
260260#![ feature( extend_one) ]
261261#![ feature( external_doc) ]
262+ #![ feature( fmt_as_str) ]
262263#![ feature( fn_traits) ]
263264#![ feature( format_args_nl) ]
264265#![ feature( gen_future) ]
Original file line number Diff line number Diff line change @@ -478,10 +478,26 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
478478 }
479479 }
480480
481+ struct StrPanicPayload ( & ' static str ) ;
482+
483+ unsafe impl BoxMeUp for StrPanicPayload {
484+ fn take_box ( & mut self ) -> * mut ( dyn Any + Send ) {
485+ Box :: into_raw ( Box :: new ( self . 0 ) )
486+ }
487+
488+ fn get ( & mut self ) -> & ( dyn Any + Send ) {
489+ & self . 0
490+ }
491+ }
492+
481493 let loc = info. location ( ) . unwrap ( ) ; // The current implementation always returns Some
482494 let msg = info. message ( ) . unwrap ( ) ; // The current implementation always returns Some
483495 crate :: sys_common:: backtrace:: __rust_end_short_backtrace ( move || {
484- rust_panic_with_hook ( & mut PanicPayload :: new ( msg) , info. message ( ) , loc) ;
496+ if let Some ( msg) = msg. as_str ( ) {
497+ rust_panic_with_hook ( & mut StrPanicPayload ( msg) , info. message ( ) , loc) ;
498+ } else {
499+ rust_panic_with_hook ( & mut PanicPayload :: new ( msg) , info. message ( ) , loc) ;
500+ }
485501 } )
486502}
487503
You can’t perform that action at this time.
0 commit comments