Skip to content

Commit

Permalink
Adapted panic message to the new stabilized PanicInfo::message me…
Browse files Browse the repository at this point in the history
…thod.

This commit removed unneccessary/depricated code paths as well as adapts the panic handler to use the newly stabilized ``PanicInfo::message``
  • Loading branch information
Vickerinox committed Aug 15, 2024
1 parent f376a72 commit 252a940
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
11 changes: 3 additions & 8 deletions src/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
}

0 comments on commit 252a940

Please sign in to comment.