From 249d63e985cc48bbcf928c0fcd8ad3d56af73e8f Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 12 Jun 2024 13:15:29 +0200 Subject: [PATCH] Use payload_as_str instead of two downcasts. --- std/src/panic.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/std/src/panic.rs b/std/src/panic.rs index 5282c00fccaf0..c5d1a893ee809 100644 --- a/std/src/panic.rs +++ b/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::() { + if let Some(payload) = self.payload_as_str() { formatter.write_str(":\n")?; formatter.write_str(payload)?; }