-
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: ICE on non-&str panic payload #66693
Comments
I guess we could support this, but we'd have to find some way to render the errors. Maybe we need to wait for const traits so we can require const Debug? |
Alternatively constck could require the argument to have type |
#![feature(const_panic)]
const _: () = core::panic!(1234);
|
Yeah, the libcore panic machinery does not support non-format-string panics. |
Aye, left out the latter of my message. |
Im hitting this ICE on stable without feature flag: struct Bug([u8; panic!(1)]); |
Hm indeed, that is interesting:
@rust-lang/wg-const-eval any idea why we go on here after seeing an error? Does this kind of behavior mean any part of CTFE is reachable on stable somehow? |
yes. We're not gating CTFE on whether there were stability (or any other static checks) failing. I've been abusing this since 1.0 to demo things on the stable compiler and never got around to fixing it. I don't even know if we have a tracking issue for it. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
On second thought, let's leave this issue for the ICE, and make a new one for "we can trigger nightly-only const code on stable because we don't abort compilation early enough": #76064. |
Given that this ICE is pre-existing, as shown by #66693 (comment), can we un-block #51999? I'd really like to see const_panic stabilized, and this seems like a minor issue to be blocking on. |
That comment is an example of accidentally partially exposing an unstable feature on stable -- a separate bug tracked in #76064. I don't see how that's an argument for shipping that feature on stable when it is broken. In particular, #76064 applies to all unstable const features. Fixing this bug here is not even that hard I think: somewhere around here
there needs to be a check that the argument has type Re: #51999, AFAIK that one is also blocked on figuring out how the diagnostics should look like, and a further concern (though maybe not blocking) is this problem. |
I guess that #3007 might make this a non-issue, where it is proposed |
For reference: rust-lang/rfcs#3007, which was recently merged. The plan is to fix the behaviour of Given that this ICE is listed as a blocker for |
No, because breaking changes are allowed to be made to unstable features without moving to a new edition; that's kinda the whole idea. The 2021 edition will effectively just extend the same restriction to all |
@RalfJung I'd like to tackle this but I'm not very experienced with the CTFE code. I get that we need to check match &args[0] {
Operand::Copy(place) | Operand::Move(place) => // how to get the type of `Place` here?
Operand::Constant(constant) => // compare constant.ty, but against what?
} For the first question, I see |
@abonander you can use |
The panic payload of the
std::panic!
macro (as passed on tobegin_panic
) is generic, but the CTFE panic support assumes it will always be an&str
. This leads to ICEs:Cc @oli-obk
The text was updated successfully, but these errors were encountered: