-
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
Tracking Issue for making ptr offset methods "const fn" #71499
Comments
Cc @rust-lang/wg-const-eval (unfortunately GH only lets org members ping teams :/ ) Note that Miri already has implementations of the relevant intrinsics but they need to be moved to rustc. |
Make pointer offset methods/intrinsics const Implements rust-lang#71499 using [the implementations from miri](https://github.com/rust-lang/miri/blob/52f5d202bdcfe8986f0615845f8d1647ab8a2c6a/src/shims/intrinsics.rs#L96-L112). However, unlike the miri implementation, I made the implementation a single function for both `offset` and `arith_offset`. I added some tests what's allowed and what's UB. Let me know if any other cases should be added. CC: @RalfJung @oli-obk
Make pointer offset methods/intrinsics const Implements rust-lang#71499 using [the implementations from miri](https://github.com/rust-lang/miri/blob/52f5d202bdcfe8986f0615845f8d1647ab8a2c6a/src/shims/intrinsics.rs#L96-L112). I added some tests what's allowed and what's UB. Let me know if any other cases should be added. CC: @RalfJung @oli-obk
Make pointer offset methods/intrinsics const Implements rust-lang#71499 using [the implementations from miri](https://github.com/rust-lang/miri/blob/52f5d202bdcfe8986f0615845f8d1647ab8a2c6a/src/shims/intrinsics.rs#L96-L112). I added some tests what's allowed and what's UB. Let me know if any other cases should be added. CC: @RalfJung @oli-obk
Make pointer offset methods/intrinsics const Implements rust-lang#71499 using [the implementations from miri](https://github.com/rust-lang/miri/blob/52f5d202bdcfe8986f0615845f8d1647ab8a2c6a/src/shims/intrinsics.rs#L96-L112). I added some tests what's allowed and what's UB. Let me know if any other cases should be added. CC: @RalfJung @oli-obk
Make pointer offset methods/intrinsics const Implements rust-lang#71499 using [the implementations from miri](https://github.com/rust-lang/miri/blob/52f5d202bdcfe8986f0615845f8d1647ab8a2c6a/src/shims/intrinsics.rs#L96-L112). I added some tests what's allowed and what's UB. Let me know if any other cases should be added. CC: @RalfJung @oli-obk
Make pointer offset methods/intrinsics const Implements rust-lang#71499 using [the implementations from miri](https://github.com/rust-lang/miri/blob/52f5d202bdcfe8986f0615845f8d1647ab8a2c6a/src/shims/intrinsics.rs#L96-L112). I added some tests what's allowed and what's UB. Let me know if any other cases should be added. CC: @RalfJung @oli-obk
One concern with these intrinsics that needs to be resolved before stabilization: for |
Hi, what's the progress on this issue? |
As decided in the unsafe const RFC, we only need to do a best effort UB check. I reviewed the methods in question and believe we can stabilize all of them. The only user visible const/runtime differences occur in the presence of UB. |
Indeed I think there is no reason to wait longer, we can stabilize this. Does someone want to prepare a stabilization PR? |
@rfcbot merge |
Team member @m-ou-se 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. |
🔔 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. This will be merged soon. |
…et, r=dtolnay Stabilize const_ptr_offset Close rust-lang#71499
The feature gate for this is
#![feature(const_ptr_offset)]
. Miri has been able to handle this for some time. This feature allows code like:The following intrinsic functions will be made
const fn
:intrinsics::offset
intrinsics::arith_offset
The allows the following
*const
/*mut
methods to beconst fn
:offset
wrapping_offset
add
/sub
wrapping_add
/wrapping_sub
The following methods are not part of this issue:
align_offset
: See align_offset guarantees #62420offset_from
: Tracked as part of Tracking issue for ptr::offset_from (feature: ptr_offset_from) #41079 and Tracking Issue for const offset_from (const_ptr_offset_from) #92980wrapping_offset_from
: Not possible across different allocationsSteps (based on #69821)
core
/alloc
/std
functions should be made const along with this.offset
andarith_offset
Unresolved Questions
offset == 0
be handled?CC: @RalfJung @oli-obk @rust-lang/wg-const-eval
The text was updated successfully, but these errors were encountered: