From d6658a5e3ddec91b5e6c4ba2d93c5abe34d9ac47 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 26 Sep 2023 14:40:50 +0200 Subject: [PATCH] Add core::panic::PanicInfo::payload() for compatibility. --- core/src/panic/panic_info.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/src/panic/panic_info.rs b/core/src/panic/panic_info.rs index 6a600e2d43123..5b784ff4f80a3 100644 --- a/core/src/panic/panic_info.rs +++ b/core/src/panic/panic_info.rs @@ -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. ///