Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d4b7304

Browse files
committedJun 11, 2024
Reorder body of begin_panic for consistency.
In the other functions, we put the struct and impl blocks first, such that the return expression can be at the end of the body as usual.
1 parent 373fb60 commit d4b7304

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed
 

‎std/src/panicking.rs

+11-17
Original file line numberDiff line numberDiff line change
@@ -687,26 +687,10 @@ pub const fn begin_panic<M: Any + Send>(msg: M) -> ! {
687687
intrinsics::abort()
688688
}
689689

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-
700690
struct Payload<A> {
701691
inner: Option<A>,
702692
}
703693

704-
impl<A: Send + 'static> Payload<A> {
705-
fn new(inner: A) -> Payload<A> {
706-
Payload { inner: Some(inner) }
707-
}
708-
}
709-
710694
unsafe impl<A: Send + 'static> PanicPayload for Payload<A> {
711695
fn take_box(&mut self) -> *mut (dyn Any + Send) {
712696
// 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) -> ! {
729713
}
730714
}
731715

732-
impl<A: Send + 'static> fmt::Display for Payload<A> {
716+
impl<A: 'static> fmt::Display for Payload<A> {
733717
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
734718
match &self.inner {
735719
Some(a) => f.write_str(payload_as_str(a)),
736720
None => process::abort(),
737721
}
738722
}
739723
}
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+
})
740734
}
741735

742736
fn payload_as_str(payload: &dyn Any) -> &str {

0 commit comments

Comments
 (0)
Failed to load comments.