Skip to content

Commit 252a940

Browse files
committed
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``
1 parent f376a72 commit 252a940

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![no_std]
22
#![feature(start)]
33
#![feature(const_fn_floating_point_arithmetic)]
4-
#![feature(panic_info_message)]
54

65
use alloc::fmt;
76
use alloc::vec::Vec;

src/panic.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,9 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
3131
None => ("(unknown file)", 0),
3232
};
3333

34-
if let Some(m) = info.message() {
35-
let _ = write!(ConsoleWriter, "PANIC: {m}\n at {file}:{line}");
36-
} else if let Some(m) = info.payload().downcast_ref::<&str>() {
37-
let _ = write!(ConsoleWriter, "PANIC: {m}\n at {file}:{line}");
38-
} else {
39-
let _ = write!(ConsoleWriter, "PANIC: (no message)\n at {file}:{line}");
40-
}
34+
let message = info.message();
35+
36+
let _ = write!(ConsoleWriter, "PANIC: {message}\n at {file}:{line}");
4137
}
42-
4338
loop {}
4439
}

0 commit comments

Comments
 (0)