File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -440,12 +440,11 @@ fn continue_panic_fmt(info: &PanicInfo) -> ! {
440
440
PanicPayload { payload, msg, string : None }
441
441
}
442
442
443
-
444
443
fn fill ( & mut self ) -> Option < & mut String > {
445
- if let Some ( msg) = self . msg . take ( ) {
444
+ if let Some ( msg) = self . msg . cloned ( ) {
446
445
Some ( self . string . get_or_insert_with ( || {
447
446
let mut s = String :: new ( ) ;
448
- drop ( s. write_fmt ( * msg) ) ;
447
+ drop ( s. write_fmt ( msg) ) ;
449
448
s
450
449
} ) )
451
450
} else {
@@ -459,6 +458,10 @@ fn continue_panic_fmt(info: &PanicInfo) -> ! {
459
458
if let Some ( string) = self . fill ( ) {
460
459
let contents = mem:: replace ( string, String :: new ( ) ) ;
461
460
Box :: into_raw ( Box :: new ( contents) )
461
+ } else if let Some ( s) = self . payload . downcast_ref :: < & str > ( ) {
462
+ Box :: into_raw ( Box :: new ( s. to_owned ( ) ) )
463
+ } else if let Some ( s) = self . payload . downcast_ref :: < String > ( ) {
464
+ Box :: into_raw ( Box :: new ( s. clone ( ) ) )
462
465
} else {
463
466
// We can't go from &(Any+Send) to Box<Any+Send> so the payload is lost here
464
467
struct NoPayload ;
@@ -467,7 +470,11 @@ fn continue_panic_fmt(info: &PanicInfo) -> ! {
467
470
}
468
471
469
472
fn get ( & mut self ) -> & ( Any + Send ) {
470
- self . payload
473
+ if let Some ( s) = self . fill ( ) {
474
+ s
475
+ } else {
476
+ self . payload
477
+ }
471
478
}
472
479
}
473
480
}
You can’t perform that action at this time.
0 commit comments