Skip to content
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

Closed
Gip-Gip opened this issue Apr 9, 2023 · 3 comments
Closed

PanicInfo nearly useless in no_std enviroment without nightly features #110098

Gip-Gip opened this issue Apr 9, 2023 · 3 comments

Comments

@Gip-Gip
Copy link

Gip-Gip commented Apr 9, 2023

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.

@jyn514
Copy link
Member

jyn514 commented Apr 9, 2023

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)

@jyn514 jyn514 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 9, 2023
@jonas-schievink
Copy link
Contributor

PanicInfo has implemented Display since 2018

@Gip-Gip
Copy link
Author

Gip-Gip commented Apr 9, 2023

PanicInfo has implemented Display since 2018

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.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 14, 2023
…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.
thomcc pushed a commit to tcdi/postgrestd that referenced this issue Jun 1, 2023
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants