defmt::{panic, assert, assert_eq}
#136
Labels
difficulty: medium
Somewhat difficult to solve
priority: low
Low priority for the Knurling team
status: needs PR
Issue just needs a Pull Request implementing the changes
type: enhancement
Enhancement or feature request
Milestone
It would be great if defmt could be used as an efficient replacement for
panic!
,assert!
, andassert_eq!
.These could work like this: If the panic should happen, a
defmt::error!
is logged with the formatting arguments, and then acore::panic!();
is raised. We might need to think about the panic payload, since a barecore::panic!()
is the same ascore::panic!("explicit panic");
, which pulls in (or might pull in)core::fmt
.Also note that we can't use
stringify!
to turn the assert expression into text, since the text has to go into the symbol name. That means thatassert!
-style macros all have to be procedural macros and stringify part of their arguments by themselves.This won't get rid of all inefficient panics. For example, indexing something out of bounds still uses
core::fmt
to format the panic string (and of course all dependencies that don't use defmt will also do that). But it should still help.The text was updated successfully, but these errors were encountered: