Skip to content

Commit

Permalink
Add core::panic::PanicInfo::payload() for compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed Jun 11, 2024
1 parent ca0bfeb commit d6658a5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions core/src/panic/panic_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ impl<'a> PanicInfo<'a> {
Some(&self.location)
}

/// Returns the payload associated with the panic.
///
/// On `core::panic::PanicInfo`, this method never returns anything useful.
/// It only exists because of compatibility with [`std::panic::PanicInfo`],
/// which used to be the same type.
///
/// See [`std::panic::PanicInfo::payload`].
///
/// [`std::panic::PanicInfo`]: ../../std/panic/struct.PanicInfo.html
/// [`std::panic::PanicInfo::payload`]: ../../std/panic/struct.PanicInfo.html#method.payload
#[deprecated(since = "1.74.0", note = "this never returns anything useful")]
#[stable(feature = "panic_hooks", since = "1.10.0")]
#[allow(deprecated, deprecated_in_future)]
pub fn payload(&self) -> &(dyn crate::any::Any + Send) {
struct NoPayload;
&NoPayload
}

/// Returns whether the panic handler is allowed to unwind the stack from
/// the point where the panic occurred.
///
Expand Down

0 comments on commit d6658a5

Please sign in to comment.