about summary refs log tree commit diff
path: root/library/core/src/panic
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2023-09-26 14:40:50 +0200
committerMara Bos <m-ou.se@m-ou.se>2024-06-11 15:46:59 +0200
commit16dfc6ddc114efa7174e2daa972916bbd2f67d87 (patch)
tree12946d1df80c4e0f61c5b4c5073321d2704641d2 /library/core/src/panic
parenta519dc85f8aa1348ec9cdc46906bbcbb9d115981 (diff)
downloadrust-16dfc6ddc114efa7174e2daa972916bbd2f67d87.tar.gz
rust-16dfc6ddc114efa7174e2daa972916bbd2f67d87.zip
Add core::panic::PanicInfo::payload() for compatibility.
Diffstat (limited to 'library/core/src/panic')
-rw-r--r--library/core/src/panic/panic_info.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/library/core/src/panic/panic_info.rs b/library/core/src/panic/panic_info.rs
index 6a600e2d431..5b784ff4f80 100644
--- a/library/core/src/panic/panic_info.rs
+++ b/library/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.
     ///