You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current documentation for core::panic::PanicInfo uses examples with downcast_ref and an unwrap. I was just porting over some old no_std code and copied over the examples for testing. However in a no_std codebase this leads to infinite recursion and probably stack exhaustion or other weird behavior depending on the design of the system implementing the panic.
Current documentation for
core::panic::PanicInfo
uses examples withdowncast_ref
and anunwrap
. I was just porting over some oldno_std
code and copied over the examples for testing. However in ano_std
codebase this leads to infinite recursion and probably stack exhaustion or other weird behavior depending on the design of the system implementing the panic.I think that the example should be changed from:
println!("panic occurred: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap());
to something like:
println!("panic occurred: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap_or("Payload unavailable"));
Or switching to
if let
to handle theNone
case.Not really that big of an issue, but I think any panic handler examples in the documentation should not be able to recursively panic.
The text was updated successfully, but these errors were encountered: