1010#![ deny( unsafe_op_in_unsafe_fn) ]
1111
1212use crate :: panic:: BacktraceStyle ;
13- use core:: panic:: { BoxMeUp , Location , PanicInfo } ;
13+ use core:: panic:: { Location , PanicInfo , PanicPayload } ;
1414
1515use crate :: any:: Any ;
1616use crate :: fmt;
@@ -47,9 +47,9 @@ extern "C" {
4747}
4848
4949extern "Rust" {
50- /// `BoxMeUp ` lazily performs allocation only when needed (this avoids
50+ /// `PanicPayload ` lazily performs allocation only when needed (this avoids
5151 /// allocations when using the "abort" panic runtime).
52- fn __rust_start_panic ( payload : & mut dyn BoxMeUp ) -> u32 ;
52+ fn __rust_start_panic ( payload : & mut dyn PanicPayload ) -> u32 ;
5353}
5454
5555/// This function is called by the panic runtime if FFI code catches a Rust
@@ -543,14 +543,14 @@ pub fn panicking() -> bool {
543543#[ cfg( not( test) ) ]
544544#[ panic_handler]
545545pub fn begin_panic_handler ( info : & PanicInfo < ' _ > ) -> ! {
546- struct PanicPayload < ' a > {
546+ struct FormatStringPayload < ' a > {
547547 inner : & ' a fmt:: Arguments < ' a > ,
548548 string : Option < String > ,
549549 }
550550
551- impl < ' a > PanicPayload < ' a > {
552- fn new ( inner : & ' a fmt:: Arguments < ' a > ) -> PanicPayload < ' a > {
553- PanicPayload { inner, string : None }
551+ impl < ' a > FormatStringPayload < ' a > {
552+ fn new ( inner : & ' a fmt:: Arguments < ' a > ) -> Self {
553+ Self { inner, string : None }
554554 }
555555
556556 fn fill ( & mut self ) -> & mut String {
@@ -566,7 +566,7 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
566566 }
567567 }
568568
569- unsafe impl < ' a > BoxMeUp for PanicPayload < ' a > {
569+ unsafe impl < ' a > PanicPayload for FormatStringPayload < ' a > {
570570 fn take_box ( & mut self ) -> * mut ( dyn Any + Send ) {
571571 // We do two allocations here, unfortunately. But (a) they're required with the current
572572 // scheme, and (b) we don't handle panic + OOM properly anyway (see comment in
@@ -580,9 +580,9 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
580580 }
581581 }
582582
583- struct StrPanicPayload ( & ' static str ) ;
583+ struct StaticStrPayload ( & ' static str ) ;
584584
585- unsafe impl BoxMeUp for StrPanicPayload {
585+ unsafe impl PanicPayload for StaticStrPayload {
586586 fn take_box ( & mut self ) -> * mut ( dyn Any + Send ) {
587587 Box :: into_raw ( Box :: new ( self . 0 ) )
588588 }
@@ -599,15 +599,15 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
599599 // `rust_panic_with_hook` construct a new `PanicInfo`?
600600 if let Some ( msg) = msg. as_str ( ) {
601601 rust_panic_with_hook (
602- & mut StrPanicPayload ( msg) ,
602+ & mut StaticStrPayload ( msg) ,
603603 info. message ( ) ,
604604 loc,
605605 info. can_unwind ( ) ,
606606 info. force_no_backtrace ( ) ,
607607 ) ;
608608 } else {
609609 rust_panic_with_hook (
610- & mut PanicPayload :: new ( msg) ,
610+ & mut FormatStringPayload :: new ( msg) ,
611611 info. message ( ) ,
612612 loc,
613613 info. can_unwind ( ) ,
@@ -637,25 +637,25 @@ pub const fn begin_panic<M: Any + Send>(msg: M) -> ! {
637637 let loc = Location :: caller ( ) ;
638638 return crate :: sys_common:: backtrace:: __rust_end_short_backtrace ( move || {
639639 rust_panic_with_hook (
640- & mut PanicPayload :: new ( msg) ,
640+ & mut Payload :: new ( msg) ,
641641 None ,
642642 loc,
643643 /* can_unwind */ true ,
644644 /* force_no_backtrace */ false ,
645645 )
646646 } ) ;
647647
648- struct PanicPayload < A > {
648+ struct Payload < A > {
649649 inner : Option < A > ,
650650 }
651651
652- impl < A : Send + ' static > PanicPayload < A > {
653- fn new ( inner : A ) -> PanicPayload < A > {
654- PanicPayload { inner : Some ( inner) }
652+ impl < A : Send + ' static > Payload < A > {
653+ fn new ( inner : A ) -> Payload < A > {
654+ Payload { inner : Some ( inner) }
655655 }
656656 }
657657
658- unsafe impl < A : Send + ' static > BoxMeUp for PanicPayload < A > {
658+ unsafe impl < A : Send + ' static > PanicPayload for Payload < A > {
659659 fn take_box ( & mut self ) -> * mut ( dyn Any + Send ) {
660660 // Note that this should be the only allocation performed in this code path. Currently
661661 // this means that panic!() on OOM will invoke this code path, but then again we're not
@@ -684,7 +684,7 @@ pub const fn begin_panic<M: Any + Send>(msg: M) -> ! {
684684/// panics, panic hooks, and finally dispatching to the panic runtime to either
685685/// abort or unwind.
686686fn rust_panic_with_hook (
687- payload : & mut dyn BoxMeUp ,
687+ payload : & mut dyn PanicPayload ,
688688 message : Option < & fmt:: Arguments < ' _ > > ,
689689 location : & Location < ' _ > ,
690690 can_unwind : bool ,
@@ -760,7 +760,7 @@ pub fn rust_panic_without_hook(payload: Box<dyn Any + Send>) -> ! {
760760
761761 struct RewrapBox ( Box < dyn Any + Send > ) ;
762762
763- unsafe impl BoxMeUp for RewrapBox {
763+ unsafe impl PanicPayload for RewrapBox {
764764 fn take_box ( & mut self ) -> * mut ( dyn Any + Send ) {
765765 Box :: into_raw ( mem:: replace ( & mut self . 0 , Box :: new ( ( ) ) ) )
766766 }
@@ -777,7 +777,7 @@ pub fn rust_panic_without_hook(payload: Box<dyn Any + Send>) -> ! {
777777/// yer breakpoints.
778778#[ inline( never) ]
779779#[ cfg_attr( not( test) , rustc_std_internal_symbol) ]
780- fn rust_panic ( msg : & mut dyn BoxMeUp ) -> ! {
780+ fn rust_panic ( msg : & mut dyn PanicPayload ) -> ! {
781781 let code = unsafe { __rust_start_panic ( msg) } ;
782782 rtabort ! ( "failed to initiate panic, error {code}" )
783783}
0 commit comments