-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
const_panic: Allow panicking in const fn #76602
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
We need to make sure certain panic lang items are skipped when qualifying min_const_fn. Signed-off-by: Joe Richey <[email protected]>
Cc @rust-lang/wg-const-eval |
r? @RalfJung |
As written, this PR would allow const-stable I discuss the long-term solution for this unfortunate UI as part of #76618. |
We don't need separate test files for std and core, we can just test everything in one file using the full paths. We also note why we use assert! instead of assert_eq! or assert_ne! Signed-off-by: Joe Richey <[email protected]>
Signed-off-by: Joe Richey <[email protected]>
Good catch, I'll amend this PR to make sure the
@ecstatic-morse, note that this change is not just to increase usability/consistency, but is a necessary prerequisite to stabilize To that end, I think we should keep this PR so that EDIT: It looks like we already use |
Ah, I had forgotten about that, thanks @ecstatic-morse!
The way we usually did things (I think) is that this change is part of stabilization. There is no good way to do it in advance.
AFAIK it already does, though? It should behave like the other language-level
Agreed, and that's a good argument for #76618.
Do you mean leave the PR as-is or leave the code in master as-is and close the PR? |
I meant to merge the PR as is (without adding the |
But the PR as-is breaks our const stability story, as @ecstatic-morse pointed out. That is a no-go. |
Sorry my point was that, even without this PR, it's already possible for
Looking at This working but |
Not sure what this demonstrates... the point is that a stable std/core function cannot do this.
Interesting. So how does this ensure it is not being used in a stable |
Oh my bad, this makes total sense. I'll see if I can get something working, if not I will close this PR in favor of #76618 or just stabilizing
OK this makes more sense. |
After some investigation, @RalfJung and @ecstatic-morse are correct. Actually having this work with good error messages makes the code very complex for little gain. Closing this PR in favor of just directly stabilizing panicing in const-fn @ecstatic-morse Nice job in catching this subtle issue. |
We need to make sure certain panic lang items are skipped when qualifying
min_const_fn. Fixes issue found here: #51999 (comment)
Signed-off-by: Joe Richey [email protected]