-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-raw-pointersArea: raw pointers, MaybeUninit, NonNullArea: raw pointers, MaybeUninit, NonNullB-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCLibs-TrackedLibs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
PR: #40943
Adds an offset_to
method to calculate the distance between two raw pointers.
List o' stuff:
- Rename to
offset_from
and make unsafe (withwrapping_offset_from
for the safe one) Tracking issue for ptr::offset_from (feature: ptr_offset_from) #41079 (comment) -- done in Introduce unsafe offset_from on pointers #49297- Should
offset_from
abort instead of panic on ZSTs?
- Should
- Given that the difference between arbitrary pointers is meaningless and subject to change at the whims of LLVM anyway, do we even want the safe version? Tracking issue for ptr::offset_from (feature: ptr_offset_from) #41079 (comment) Experience reports from the field appreciated.
- Should there be more methods like this with different restrictions (to allow nuw/nsw, perhaps) or that return
usize
(like how isize-takingoffset
is more conveniently done with usize-takingadd
these days) - Ensure that our safety requirements align with the proposed llvm.psub [LLVM9+] Use llvm.psub in offset_from #57818
stanislav-tkachratijas
Metadata
Metadata
Assignees
Labels
A-raw-pointersArea: raw pointers, MaybeUninit, NonNullArea: raw pointers, MaybeUninit, NonNullB-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCLibs-TrackedLibs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.