Tracking Issue for pointer_bytes_offsets · Issue #96283 · rust-lang/rust · GitHu...
source link: https://github.com/rust-lang/rust/issues/96283
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Tracking Issue for pointer_bytes_offsets #96283
2 of 4 tasks
Tracked by
Comments
Feature gates:
This is a tracking issue for the pointer_byte_offsets raw pointer conveniences like Public API
Steps / HistoryUnresolved Questions
|
added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature.
labels
Contributor
Author
To clarify the open question's concerns a bit: if you make a ref-slice and then cast it to a raw-slice, offsetting the raw pointer will not change the slice's len, but you can't actually turn the offset slice back into a ref, because (at least under the strictest rules) the original ref-slice has provenance over only its exact range, and so derived pointers cannot access outside the range. Creating the offset ref-slice is trying to assert provenance over additional bytes you don't have permission to access. Similarly, trait-object-refs will make you sad if you do that. This can only be soundly used (meaningfully) if you from_raw_parts the raw-DST from a raw pointer with provenance over the whole "array" you want to stride through. So like, in general you need to write something like (pseudocode of the general pattern):
(CC @RalfJung since this is an interesting stacked borrows example, no need to reply if there's nothing more to say.) |
Member
@Gankra actually, I think allowing these methods take pointers to DST unlocks a lot of abilities for custom DSTs. In particular |
Member
I want to propose to stabilize these methods! (can someone open an fcp?) Stabilization reportImplementation History
API Summary
Experience Report#99113, #100819 and #100030 refactored some std code into using these methods simplifying the code. These methods allow custom This also allows to polyfil |
Member
Pondering: does That would allow things like EDIT: this was updated in #103489 |
Contributor
I have a question regarding the I just had the situation today, where I needed the offset between 2 bytes slices (one is a subslice of the other) and failed to see why I should use the unsafe But I'm wondering, what are safe examples in which I should use |
Member
|
Member
Another advantage of offset_from is that it can be used in For some time we had safe variants of |
What is the status of |
added the I-libs-api-nominated Indicates that an issue has been nominated for discussion during a libs-api team meeting. label
Member
I'm nominating this for t-libs-api discussion. I propose to stabilize those APIs, see the stabilization report: #96283 (comment). (it looks like I forgot to make sure t-libs-api sees the report, oops 💀) |
Member
@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. |
added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised.
and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
labels
🔔 This is now entering its final comment period, as per the review above. 🔔 |
removed the I-libs-api-nominated Indicates that an issue has been nominated for discussion during a libs-api team meeting. label
Contributor
Member
Discoverability should get better with stabilization. We don't mention unstable things from the docs for stable things, but as part of stabilization we can add something like this to
to help people find it. |
Member
I have to always try a bunch of permutations when calling the "bytes" methods, I can never remember where the |
Contributor
The same argument could be made for |
Contributor
I think that saturating/wrapping/checked arithmetic are actually the exception and not the standard, almost everything else follows Not that that's any strong justification, but the names here still seem a bit backwards to me. But yeah... it's late 🙂 |
Contributor
We are in agreement. I would have liked the |
added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting
and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised.
labels
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. |
Member
We don't need to restart an FCP clock for this but I'd still like to be sure the team has seen the important discussion that took place after the 3 currently checked boxes. Thank you for raising this @tgross35. @rust-lang/libs-api: please have a look at #96283 (comment) which is an insightful breakdown. I think the current set of names (see top of this issue) continue to be my first choice for word order. @rfcbot poll libs-api Proceed with current word order? |
Team member @dtolnay has asked teams: T-libs-api, for consensus on:
|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
No one assigned
None yet
No milestone
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK