@@ -340,6 +340,7 @@ fn panic_handler(info: &PanicInfo<'_>) -> ! {
340
340
use crate :: fmt:: Write ;
341
341
342
342
let inner = self . inner ;
343
+ // Lazily, the first time this gets called, run the actual string formatting.
343
344
self . string . get_or_insert_with ( || {
344
345
let mut s = String :: new ( ) ;
345
346
drop ( s. write_fmt ( * inner) ) ;
@@ -349,7 +350,7 @@ fn panic_handler(info: &PanicInfo<'_>) -> ! {
349
350
}
350
351
351
352
unsafe impl < ' a > BoxMeUp for PanicPayload < ' a > {
352
- fn box_me_up ( & mut self ) -> * mut ( dyn Any + Send ) {
353
+ fn take_box ( & mut self ) -> * mut ( dyn Any + Send ) {
353
354
let contents = mem:: take ( self . fill ( ) ) ;
354
355
Box :: into_raw ( Box :: new ( contents) )
355
356
}
@@ -407,10 +408,10 @@ pub fn begin_panic<M: Any + Send>(msg: M, file_line_col: &(&'static str, u32, u3
407
408
}
408
409
409
410
unsafe impl < A : Send + ' static > BoxMeUp for PanicPayload < A > {
410
- fn box_me_up ( & mut self ) -> * mut ( dyn Any + Send ) {
411
+ fn take_box ( & mut self ) -> * mut ( dyn Any + Send ) {
411
412
let data = match self . inner . take ( ) {
412
413
Some ( a) => Box :: new ( a) as Box < dyn Any + Send > ,
413
- None => Box :: new ( ( ) ) ,
414
+ None => Box :: new ( ( ) ) , // this should never happen: we got called twice
414
415
} ;
415
416
Box :: into_raw ( data)
416
417
}
@@ -488,7 +489,7 @@ pub fn update_count_then_panic(msg: Box<dyn Any + Send>) -> ! {
488
489
struct RewrapBox ( Box < dyn Any + Send > ) ;
489
490
490
491
unsafe impl BoxMeUp for RewrapBox {
491
- fn box_me_up ( & mut self ) -> * mut ( dyn Any + Send ) {
492
+ fn take_box ( & mut self ) -> * mut ( dyn Any + Send ) {
492
493
Box :: into_raw ( mem:: replace ( & mut self . 0 , Box :: new ( ( ) ) ) )
493
494
}
494
495
0 commit comments