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

The 2021 panic macro no longer works in const functions #87466

Closed
AaronKutch opened this issue Jul 26, 2021 · 2 comments · Fixed by #86998
Closed

The 2021 panic macro no longer works in const functions #87466

AaronKutch opened this issue Jul 26, 2021 · 2 comments · Fixed by #86998
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. A-edition-2021 Area: The 2021 edition A-error-handling Area: Error handling requires-nightly This issue requires a nightly compiler in some way.

Comments

@AaronKutch
Copy link
Contributor

I encountered one issue when trying to migrate my crates to edition 2021. This no longer compiles:

#![feature(const_panic)]

pub const fn f() {
    panic!("important info");
}

I understand that this requires a nightly feature to observe, but const_panic was really close to stabilizing and I use this in a lot of places. Is it possible to adjust the underlying format_args to be const with a static string input, or is there something else I should use? I don't want to go back to using the weird out-of-bounds indexing hack when trying to convey messages from a const function.

@inquisitivecrystal inquisitivecrystal added A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. A-edition-2021 Area: The 2021 edition A-error-handling Area: Error handling C-bug Category: This is a bug. and removed C-bug Category: This is a bug. labels Jul 26, 2021
@inquisitivecrystal
Copy link
Contributor

This is a known problem, unfortunately. It appears to be a result of the changes made to the panic macro to standardize its behavior.

@fee1-dead
Copy link
Member

See #86998

@m-ou-se m-ou-se linked a pull request Jul 28, 2021 that will close this issue
@m-ou-se m-ou-se added the requires-nightly This issue requires a nightly compiler in some way. label Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-fn Area: const fn foo(..) {..}. Pure functions which can be applied at compile time. A-edition-2021 Area: The 2021 edition A-error-handling Area: Error handling requires-nightly This issue requires a nightly compiler in some way.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants