-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Acknowledge that [CONST; N]
is stable
#79270
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
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
r=me with lang team sign-off |
Regarding dropping, I now added a test to make sure that This is in contrast to |
We discussed this in the lang team meeting today and decided to go ahead and @rfcbot fcp merge I agree that we might as well just allow this to work for something that's just the ident (well, a path) of a |
Team member @scottmcm has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/const-repeat.rs
Outdated
Show resolved
Hide resolved
Did you have a chance to talk about the issue with |
e029bbb
to
f2ced78
Compare
🔔 This is now entering its final comment period, as per the review above. 🔔 |
@RalfJung we discussed this again today in the triage meeting, and agreed that Another piece of that which came to mind today is that since |
(Dropping nomination - I don't think this needs further lang discussion right now) |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. The RFC will be merged soon. |
⌛ Testing commit f2ced78149c5cc44221492869dfae18bbaa51019 with merge 3e8060c917c39b726906aafca7f7b1341ff44866... |
💔 Test failed - checks-actions |
f2ced78
to
7f3e18c
Compare
Rebased... but then I realized this is a network problem:
@bors retry |
@bors r=oli-obk |
📌 Commit 7f3e18c has been approved by |
☀️ Test successful - checks-actions |
When
const_in_array_repeat_expressions
(RFC 2203) got unstably implemented as part of #61749, accidentally, the special case of repeating a constant got stabilized immediately. That is why the following code works on stable:In contrast, if we had written
[expr; 2]
for some expression that is not literally a constant but could be evaluated at compile-time (e.g.(EMPTY,).0
), this would have failed.We could take back this stabilization as it was clearly accidental. However, I propose we instead just officially accept this and stabilize a small subset of RFC 2203, while leaving the more complex case of general expressions that could be evaluated at compile-time unstable. Making that case work well is pretty much blocked on inline
const
expressions (to avoid relying too much on implicit promotion), so it could take a bit until it comes to full fruition.[CONST; N]
is an uncontroversial subset of this feature that has no semantic ambiguities, does not rely on promotion, and basically provides the full expressive power of RFC 2203 but without the convenience (people have to define constants to repeat them, possibly using associated consts if generics are involved).Well, I said "no semantic ambiguities", that is only almost true... the one point I am not sure about is
[CONST; 0]
. There are two possible behaviors here: either this is equivalent tolet x = CONST; [x; 0]
, or it is a NOP (if we argue that the constant is never actually instantiated). The difference between the two is that ifCONST
has a destructor, it should run in the former case (but currently doesn't, due to #74836); but should not run if it is considered a NOP. For regular[x; 0]
there seems to be consensus on running drop (there isn't really an alternative); any opinions for theCONST
special case? Should this instantiate the const only to immediately run its destructors? That seems somewhat silly to me. After all, thelet
-expansion does not work in general, forN > 1
.Cc @rust-lang/lang @rust-lang/wg-const-eval
Cc #49147