-
Notifications
You must be signed in to change notification settings - Fork 13.3k
stabilize const_swap #134757
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
stabilize const_swap #134757
Conversation
Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @rust-lang/wg-const-eval Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri The Miri subtree was changed cc @rust-lang/miri Some changes occurred to the CTFE machinery cc @rust-lang/wg-const-eval |
src/tools/miri/tests/fail/intrinsics/typed-swap-invalid-scalar.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: scottmcm <[email protected]>
// The initializer of constants and statics will get validated separately | ||
// after the constant has been fully evaluated. While we could fall back to the default | ||
// code path, that will cause -Zenforce-validity to cycle on static initializers. | ||
// Reading from a static's memory is not allowed during its evaluation, and will always | ||
// trigger a cycle error. Validation must read from the memory of the current item. | ||
// For Miri this means we do not validate the root frame return value, | ||
// but Miri anyway calls `read_target_isize` on that so separate validation | ||
// is not needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment is outdated ever since we changed how statics get interned and when exactly validation runs... but if there's still a risk of an ICE here I am sure matthiaskrgr will find it in no time and then we'll have a testcase. ;)
I have zero concerns with stabilizing this intrinsic. I added it in #122582 with no specific intention to check things better in const, just a want to be able to detect layouts in a way that doesn't work in libcore source code. If I were remaking that PR today it might just have been So |
I would object to that, given that the intrinsic docs clearly say that it is a typed swap, and the fallback implementation uses an untyped swap. |
@bors r=scottmcm |
☀️ Test successful - checks-actions |
I agree -- would have needed to be a different phrasing to make that reasonable, unsure exactly how. |
Finished benchmarking commit (4e5fec2): comparison URL. Overall result: ❌✅ regressions and improvements - no action needed@rustbot label: -perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (secondary -4.4%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (secondary 3.2%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 758.809s -> 761.022s (0.29%) |
libs-api FCP passed in #83163.
However, I only just realized that this actually involves an intrinsic. The intrinsic could be implemented entirely with existing stable const functionality, but we choose to make it a primitive to be able to detect more UB. So nominating for @rust-lang/lang to make sure they are aware; I leave it up to them whether they want to FCP this.
While at it I also renamed the intrinsic to make the "nonoverlapping" constraint more clear.
Fixes #83163