Reorder body of begin_panic for consistency. · model-checking/verify-rust-std@d4b7304 (original) (raw)

Original file line number Diff line number Diff line change
@@ -687,26 +687,10 @@ pub const fn begin_panic<M: Any + Send>(msg: M) -> ! {
687 687 intrinsics::abort()
688 688 }
689 689
690 -let loc = Location::caller();
691 -return crate::sys_common::backtrace::__rust_end_short_backtrace(move |
692 -rust_panic_with_hook(
693 -&mut Payload::new(msg),
694 - loc,
695 -/* can_unwind */ true,
696 -/* force_no_backtrace */ false,
697 -)
698 -});
699 -
700 690 struct Payload<A> {
701 691 inner: Option<A>,
702 692 }
703 693
704 -impl<A: Send + 'static> Payload<A> {
705 -fn new(inner: A) -> Payload<A> {
706 -Payload { inner: Some(inner) }
707 -}
708 -}
709 -
710 694 unsafe impl<A: Send + 'static> PanicPayload for Payload<A> {
711 695 fn take_box(&mut self) -> *mut (dyn Any + Send) {
712 696 // Note that this should be the only allocation performed in this code path. Currently
@@ -729,14 +713,24 @@ pub const fn begin_panic<M: Any + Send>(msg: M) -> ! {
729 713 }
730 714 }
731 715
732 -impl<A: Send + 'static> fmt::Display for Payload<A> {
716 +impl<A: 'static> fmt::Display for Payload<A> {
733 717 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
734 718 match &self.inner {
735 719 Some(a) => f.write_str(payload_as_str(a)),
736 720 None => process::abort(),
737 721 }
738 722 }
739 723 }
724 +
725 +let loc = Location::caller();
726 +crate::sys_common::backtrace::__rust_end_short_backtrace(move |
727 +rust_panic_with_hook(
728 +&mut Payload { inner: Some(msg) },
729 + loc,
730 +/* can_unwind */ true,
731 +/* force_no_backtrace */ false,
732 +)
733 +})
740 734 }
741 735
742 736 fn payload_as_str(payload: &dyn Any) -> &str {