-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PanicInfo nearly useless in no_std enviroment without nightly features #110098
Comments
This is a duplicate of #66745. I'm sorry you're frustrated by the slow progress here, but that's the nature of open source projects, work only happens if someone volunteers to work on it. I'm happy to give you pointers on how to move it towards stabilization if you're interested in working on that; it looks like there's only a small amount of work left: #66745 (comment) |
|
My bad I missed that, most code examples I've seen extract the value from the payload and I was too focused on that I didn't even look at the traits. |
…ohnTitor Use `Display` in top-level example for `PanicInfo` Addresses rust-lang#110098. This confused me as well, when I was writing a `no_std` panic handler for the first time, so here's a better top-level example. `Display` is stable, prints the `.message()` if available, and falls back to `.payload().downcast_ref<&str>()` if the message is not available. So this example should provide strictly more information and also work for formatted panics. The old example still exists on the `payload` method.
Use `Display` in top-level example for `PanicInfo` Addresses rust-lang/rust#110098. This confused me as well, when I was writing a `no_std` panic handler for the first time, so here's a better top-level example. `Display` is stable, prints the `.message()` if available, and falls back to `.payload().downcast_ref<&str>()` if the message is not available. So this example should provide strictly more information and also work for formatted panics. The old example still exists on the `payload` method.
I'm writing a simple panic handler for my embedded system which flashes an LED in pseudo-morse code to tell the user what error occurred. I need the error message, however I can't get it without the nightly
PanicInfo.message()
. There is no reason I should be forced to use nightly to use such a basic feature.I get why it may have not been stabilized immediately, but
.message()
was basically left to die in 2019 and my panic handler is 100% useless without.message()
since panics using core have no payload.It is very frustrating to develop a substantial firmware and not have a user friendly panic handler without relying on unstable features, especially since
.message()
has been unstable for over 4 years. There is no reason this important feature shouldn't have been addressed by now.The text was updated successfully, but these errors were encountered: