From 252a9400f6590c49e89185aab4115088ac0e1afb Mon Sep 17 00:00:00 2001 From: Vikrinox <51887867+Vickerinox@users.noreply.github.com> Date: Thu, 15 Aug 2024 10:50:21 +0200 Subject: [PATCH] Adapted panic message to the new stabilized ``PanicInfo::message`` method. This commit removed unneccessary/depricated code paths as well as adapts the panic handler to use the newly stabilized ``PanicInfo::message`` --- src/lib.rs | 1 - src/panic.rs | 11 +++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 336799e..07be73d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,6 @@ #![no_std] #![feature(start)] #![feature(const_fn_floating_point_arithmetic)] -#![feature(panic_info_message)] use alloc::fmt; use alloc::vec::Vec; diff --git a/src/panic.rs b/src/panic.rs index 477b18a..28cc38b 100644 --- a/src/panic.rs +++ b/src/panic.rs @@ -31,14 +31,9 @@ fn panic(info: &core::panic::PanicInfo) -> ! { None => ("(unknown file)", 0), }; - if let Some(m) = info.message() { - let _ = write!(ConsoleWriter, "PANIC: {m}\n at {file}:{line}"); - } else if let Some(m) = info.payload().downcast_ref::<&str>() { - let _ = write!(ConsoleWriter, "PANIC: {m}\n at {file}:{line}"); - } else { - let _ = write!(ConsoleWriter, "PANIC: (no message)\n at {file}:{line}"); - } + let message = info.message(); + + let _ = write!(ConsoleWriter, "PANIC: {message}\n at {file}:{line}"); } - loop {} }