Add core::panic::PanicInfo::payload() for compatibility. · model-checking/verify-rust-std@d6658a5 (original) (raw)

Original file line number Diff line number Diff line change
@@ -81,6 +81,24 @@ impl<'a> PanicInfo<'a> {
81 81 Some(&self.location)
82 82 }
83 83
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 +
84 102 /// Returns whether the panic handler is allowed to unwind the stack from
85 103 /// the point where the panic occurred.
86 104 ///