-
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
Tracking issue for RFC 2341, Allow locals and destructuring in const fn #48821
Comments
It's a bit trickier, because Also, was |
@eddyb Feel free to edit the issue description =)
Yes, because (quoting the summary):
|
A question about the "Drawbacks" section from the original RFC:
Can you elaborate on this? Is this just referring to something like |
Not a drawback really, but a note that this is new behaviour, because before you could never modify the same memory twice, only emulate the same program behaviour via const fn. |
This works now on nightly (behind a feature gate). Please play around with this feature liberally and report any findings! Any help in documenting and pushing it over the stabilization line is appreciated. |
This comment has been minimized.
This comment has been minimized.
Imo it would be fine if added behind its own feature gate. So if you're looking for something easy to do:
|
Short-circuiting operators need to be fixed before stabilizing |
I already added it to the OP ;) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
We could stabilize Due to backwards compatibility constraints we cannot make cc @Centril |
@oli-obk Hmm... there are a bunch of bug reports cited in #48821 (comment)... we'd have to feel comfortable with the implementation before stabilizing. However, my main question re. stabilizing is whether stabilizing |
I have a fix ready for these bugs in #56070
You can do things like fn bar() -> [u32; 500] {
let mut foo = [0; 500];
foo[3] = 42;
foo
} Or just generally make your code more readable in case the return expression is very complex. |
Cool. :)
I somehow doubt expressions can become complex without any sort of control flow but I suppose it doesn't hurt. Clearly enough time has passed since it was landed in nightly... Could you? prepare:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Does this tracking issue include mutable references? Or is that a separate RFC/tracking issue? |
Mutable references require their own full rfc imo. There are so many edge cases. I have started tracking some in rust-lang/const-eval#16 |
Stabilization proposed: #57175 (comment) |
Stabilized in #57175; Documentation issue: rust-lang/reference#506 Everything is done so closing therefore. |
This is a tracking issue for the RFC "Allow locals and destructuring in const fn" (rust-lang/rfcs#2341).
Steps:
const_let
reference#506)let
bindings and destructuring in constants and const fn #57175 (comment))Unresolved questions:
None.
The text was updated successfully, but these errors were encountered: