about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/core/src/panic/panic_info.rs9
-rw-r--r--library/std/src/panic.rs5
2 files changed, 5 insertions, 9 deletions
diff --git a/library/core/src/panic/panic_info.rs b/library/core/src/panic/panic_info.rs
index df8f441bf35..78cf1d2e98e 100644
--- a/library/core/src/panic/panic_info.rs
+++ b/library/core/src/panic/panic_info.rs
@@ -29,9 +29,8 @@ impl<'a> PanicInfo<'a> {
         PanicInfo { location, message, can_unwind, force_no_backtrace }
     }
 
-    /// If the `panic!` macro from the `core` crate (not from `std`)
-    /// was used with a formatting string and some additional arguments,
-    /// returns that message ready to be used for example with [`fmt::write`]
+    /// The message that was given to the `panic!` macro,
+    /// ready to be formatted with e.g. [`fmt::write`].
     #[must_use]
     #[unstable(feature = "panic_info_message", issue = "66745")]
     pub fn message(&self) -> fmt::Arguments<'_> {
@@ -72,7 +71,7 @@ impl<'a> PanicInfo<'a> {
 
     /// Returns the payload associated with the panic.
     ///
-    /// On `core::panic::PanicInfo`, this method never returns anything useful.
+    /// On this type, `core::panic::PanicInfo`, this method never returns anything useful.
     /// It only exists because of compatibility with [`std::panic::PanicHookInfo`],
     /// which used to be the same type.
     ///
@@ -80,7 +79,7 @@ impl<'a> PanicInfo<'a> {
     ///
     /// [`std::panic::PanicHookInfo`]: ../../std/panic/struct.PanicHookInfo.html
     /// [`std::panic::PanicHookInfo::payload`]: ../../std/panic/struct.PanicHookInfo.html#method.payload
-    #[deprecated(since = "1.77.0", note = "this never returns anything useful")]
+    #[deprecated(since = "1.81.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) {
diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs
index 5282c00fcca..c5d1a893ee8 100644
--- a/library/std/src/panic.rs
+++ b/library/std/src/panic.rs
@@ -202,10 +202,7 @@ impl fmt::Display for PanicHookInfo<'_> {
     fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
         formatter.write_str("panicked at ")?;
         self.location.fmt(formatter)?;
-        if let Some(payload) = self.payload.downcast_ref::<&'static str>() {
-            formatter.write_str(":\n")?;
-            formatter.write_str(payload)?;
-        } else if let Some(payload) = self.payload.downcast_ref::<String>() {
+        if let Some(payload) = self.payload_as_str() {
             formatter.write_str(":\n")?;
             formatter.write_str(payload)?;
         }