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
@@ -565,14 +565,14 @@ pub fn panicking() -> bool {
565565#[ cfg( not( test) ) ]
566566#[ panic_handler]
567567pub fn begin_panic_handler ( info : & PanicInfo < ' _ > ) -> ! {
568- struct PanicPayload < ' a > {
568+ struct FormatStringPayload < ' a > {
569569 inner : & ' a fmt:: Arguments < ' a > ,
570570 string : Option < String > ,
571571 }
572572
573- impl < ' a > PanicPayload < ' a > {
574- fn new ( inner : & ' a fmt:: Arguments < ' a > ) -> PanicPayload < ' a > {
575- PanicPayload { inner, string : None }
573+ impl < ' a > FormatStringPayload < ' a > {
574+ fn new ( inner : & ' a fmt:: Arguments < ' a > ) -> Self {
575+ Self { inner, string : None }
576576 }
577577
578578 fn fill ( & mut self ) -> & mut String {
@@ -588,7 +588,7 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
588588 }
589589 }
590590
591- unsafe impl < ' a > BoxMeUp for PanicPayload < ' a > {
591+ unsafe impl < ' a > PanicPayload for FormatStringPayload < ' a > {
592592 fn take_box ( & mut self ) -> * mut ( dyn Any + Send ) {
593593 // We do two allocations here, unfortunately. But (a) they're required with the current
594594 // scheme, and (b) we don't handle panic + OOM properly anyway (see comment in
@@ -602,9 +602,9 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
602602 }
603603 }
604604
605- struct StrPanicPayload ( & ' static str ) ;
605+ struct StaticStrPayload ( & ' static str ) ;
606606
607- unsafe impl BoxMeUp for StrPanicPayload {
607+ unsafe impl PanicPayload for StaticStrPayload {
608608 fn take_box ( & mut self ) -> * mut ( dyn Any + Send ) {
609609 Box :: into_raw ( Box :: new ( self . 0 ) )
610610 }
@@ -621,15 +621,15 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
621621 // `rust_panic_with_hook` construct a new `PanicInfo`?
622622 if let Some ( msg) = msg. as_str ( ) {
623623 rust_panic_with_hook (
624- & mut StrPanicPayload ( msg) ,
624+ & mut StaticStrPayload ( msg) ,
625625 info. message ( ) ,
626626 loc,
627627 info. can_unwind ( ) ,
628628 info. force_no_backtrace ( ) ,
629629 ) ;
630630 } else {
631631 rust_panic_with_hook (
632- & mut PanicPayload :: new ( msg) ,
632+ & mut FormatStringPayload :: new ( msg) ,
633633 info. message ( ) ,
634634 loc,
635635 info. can_unwind ( ) ,
@@ -659,25 +659,25 @@ pub const fn begin_panic<M: Any + Send>(msg: M) -> ! {
659659 let loc = Location :: caller ( ) ;
660660 return crate :: sys_common:: backtrace:: __rust_end_short_backtrace ( move || {
661661 rust_panic_with_hook (
662- & mut PanicPayload :: new ( msg) ,
662+ & mut Payload :: new ( msg) ,
663663 None ,
664664 loc,
665665 /* can_unwind */ true ,
666666 /* force_no_backtrace */ false ,
667667 )
668668 } ) ;
669669
670- struct PanicPayload < A > {
670+ struct Payload < A > {
671671 inner : Option < A > ,
672672 }
673673
674- impl < A : Send + ' static > PanicPayload < A > {
675- fn new ( inner : A ) -> PanicPayload < A > {
676- PanicPayload { inner : Some ( inner) }
674+ impl < A : Send + ' static > Payload < A > {
675+ fn new ( inner : A ) -> Payload < A > {
676+ Payload { inner : Some ( inner) }
677677 }
678678 }
679679
680- unsafe impl < A : Send + ' static > BoxMeUp for PanicPayload < A > {
680+ unsafe impl < A : Send + ' static > PanicPayload for Payload < A > {
681681 fn take_box ( & mut self ) -> * mut ( dyn Any + Send ) {
682682 // Note that this should be the only allocation performed in this code path. Currently
683683 // this means that panic!() on OOM will invoke this code path, but then again we're not
@@ -706,7 +706,7 @@ pub const fn begin_panic<M: Any + Send>(msg: M) -> ! {
706706/// panics, panic hooks, and finally dispatching to the panic runtime to either
707707/// abort or unwind.
708708fn rust_panic_with_hook (
709- payload : & mut dyn BoxMeUp ,
709+ payload : & mut dyn PanicPayload ,
710710 message : Option < & fmt:: Arguments < ' _ > > ,
711711 location : & Location < ' _ > ,
712712 can_unwind : bool ,
@@ -782,7 +782,7 @@ pub fn rust_panic_without_hook(payload: Box<dyn Any + Send>) -> ! {
782782
783783 struct RewrapBox ( Box < dyn Any + Send > ) ;
784784
785- unsafe impl BoxMeUp for RewrapBox {
785+ unsafe impl PanicPayload for RewrapBox {
786786 fn take_box ( & mut self ) -> * mut ( dyn Any + Send ) {
787787 Box :: into_raw ( mem:: replace ( & mut self . 0 , Box :: new ( ( ) ) ) )
788788 }
@@ -799,7 +799,7 @@ pub fn rust_panic_without_hook(payload: Box<dyn Any + Send>) -> ! {
799799/// yer breakpoints.
800800#[ inline( never) ]
801801#[ cfg_attr( not( test) , rustc_std_internal_symbol) ]
802- fn rust_panic ( msg : & mut dyn BoxMeUp ) -> ! {
802+ fn rust_panic ( msg : & mut dyn PanicPayload ) -> ! {
803803 let code = unsafe { __rust_start_panic ( msg) } ;
804804 rtabort ! ( "failed to initiate panic, error {code}" )
805805}
0 commit comments