@@ -340,6 +340,7 @@ fn panic_handler(info: &PanicInfo<'_>) -> ! {
340340 use crate :: fmt:: Write ;
341341
342342 let inner = self . inner ;
343+ // Lazily, the first time this gets called, run the actual string formatting.
343344 self . string . get_or_insert_with ( || {
344345 let mut s = String :: new ( ) ;
345346 drop ( s. write_fmt ( * inner) ) ;
@@ -349,7 +350,7 @@ fn panic_handler(info: &PanicInfo<'_>) -> ! {
349350 }
350351
351352 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 ) {
353354 let contents = mem:: take ( self . fill ( ) ) ;
354355 Box :: into_raw ( Box :: new ( contents) )
355356 }
@@ -407,10 +408,10 @@ pub fn begin_panic<M: Any + Send>(msg: M, file_line_col: &(&'static str, u32, u3
407408 }
408409
409410 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 ) {
411412 let data = match self . inner . take ( ) {
412413 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
414415 } ;
415416 Box :: into_raw ( data)
416417 }
@@ -488,7 +489,7 @@ pub fn update_count_then_panic(msg: Box<dyn Any + Send>) -> ! {
488489 struct RewrapBox ( Box < dyn Any + Send > ) ;
489490
490491 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 ) {
492493 Box :: into_raw ( mem:: replace ( & mut self . 0 , Box :: new ( ( ) ) ) )
493494 }
494495
0 commit comments