File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 259
259
#![ feature( exhaustive_patterns) ]
260
260
#![ feature( extend_one) ]
261
261
#![ feature( external_doc) ]
262
+ #![ feature( fmt_as_str) ]
262
263
#![ feature( fn_traits) ]
263
264
#![ feature( format_args_nl) ]
264
265
#![ feature( gen_future) ]
Original file line number Diff line number Diff line change @@ -478,10 +478,26 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
478
478
}
479
479
}
480
480
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
+
481
493
let loc = info. location ( ) . unwrap ( ) ; // The current implementation always returns Some
482
494
let msg = info. message ( ) . unwrap ( ) ; // The current implementation always returns Some
483
495
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
+ }
485
501
} )
486
502
}
487
503
You can’t perform that action at this time.
0 commit comments