-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
stop promoting union field accesses in 'const' #77526
Conversation
r? @lcnr (rust_highfive has picked a reviewer for you, use r? to override) |
This will need a crater run. @bors try |
⌛ Trying commit d727f64 with merge f47dd4da3ae8c32c9e65d307bfe640b143e674df... |
☀️ Try build successful - checks-actions, checks-azure |
@craterbot check |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🎉 Experiment
|
Not a single one of these looks like a true regression to me. :) |
@rfcbot merge |
Team member @joshtriplett 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. |
@rfcbot fcp reviewed |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
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 d727f64 with merge 01aa42f71e23887973836b478d9600907ee3e01a... |
💔 Test failed - checks-actions |
looks spurious @bors retry |
⌛ Testing commit d727f64 with merge d080ec54500edb05029a3d5dc3471e7ac34779bb... |
💔 Test failed - checks-actions |
looks spurious, but it's the second time in a row, so cc @rust-lang/infra |
We can still try to |
That is fixed by #78316. |
☀️ Test successful - checks-actions |
validate promoteds Turn on const-value validation for promoteds. This is made possible now that rust-lang#67534 is resolved. I don't think this is a breaking change. We don't promote any unsafe operation any more (since rust-lang#77526 landed). We *do* promote `const fn` calls under some circumstances (in `const`/`static` initializers), but union field access and similar operations are not allowed in `const fn`. So now is a perfect time to add this check. :D r? `@oli-obk` Fixes rust-lang#67465
Turns out that promotion of union field accesses is the only difference between "promotion in
const
/static
bodies" and "explicit promotion". So if we can remove this, we have finally achieved what I thought to already be the case -- that the bodies ofconst
/static
initializers behave the same as explicit promotion contexts.The reason we do not want to promote union field accesses is that they can introduce UB, i.e., they can go wrong. We want to minimize the ways promoteds can fail to evaluate. Also this change makes things more consistent overall, removing a special case that was added without much consideration (as far as I can tell).
Cc @rust-lang/wg-const-eval