Skip to content

Commit d6658a5

Browse files
committed
Add core::panic::PanicInfo::payload() for compatibility.
1 parent ca0bfeb commit d6658a5

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

core/src/panic/panic_info.rs

+18
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,24 @@ impl<'a> PanicInfo<'a> {
8181
Some(&self.location)
8282
}
8383

84+
/// Returns the payload associated with the panic.
85+
///
86+
/// On `core::panic::PanicInfo`, this method never returns anything useful.
87+
/// It only exists because of compatibility with [`std::panic::PanicInfo`],
88+
/// which used to be the same type.
89+
///
90+
/// See [`std::panic::PanicInfo::payload`].
91+
///
92+
/// [`std::panic::PanicInfo`]: ../../std/panic/struct.PanicInfo.html
93+
/// [`std::panic::PanicInfo::payload`]: ../../std/panic/struct.PanicInfo.html#method.payload
94+
#[deprecated(since = "1.74.0", note = "this never returns anything useful")]
95+
#[stable(feature = "panic_hooks", since = "1.10.0")]
96+
#[allow(deprecated, deprecated_in_future)]
97+
pub fn payload(&self) -> &(dyn crate::any::Any + Send) {
98+
struct NoPayload;
99+
&NoPayload
100+
}
101+
84102
/// Returns whether the panic handler is allowed to unwind the stack from
85103
/// the point where the panic occurred.
86104
///

0 commit comments

Comments
 (0)