-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 ptr::slice_from_raw_parts[_mut] #68234
Conversation
Hm right let's inform the bots about the review assignee properly I confused it by asking for a group 😅 So I just picked who GitHub recommended r? @oli-obk |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Actual error: Click to expand the log.
cc @TimNN: error fragments did not include error message (rebased) |
946656d
to
5685650
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
5a36e2f
to
b8cd7ed
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
b8cd7ed
to
f76177c
Compare
This is two free functions in the pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {…}
pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] {…} @rfcbot fcp merge |
Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
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 concern &raw I feel that the usefulness of this feature is tied with that of |
@Amanieu the reason I want these methods actually has nothing to do with The problem I'm dealing with is pointer provinence. I don't know (in my current generic API setup) whether the raw pointer I'm working with is from a If I use If I use And this is ignoring the case of potentially misaligned or null pointers, which are instant UB to use with the reference functions. Ultimately, I think there are enough reasons to have these functions, even if they aren't strictly required by the memory model (for aligned non-null pointers), because they're a simple helper API when you're working with pointers to begin with that sidestep all of the thorny questions around references in pointer workloads that will remain no matter the specific memory model. TL;DR: these functions are mainly useful when you don't know provenance (dependent on memory model), alignment, or null (definitely UB today). |
I'm convinced! @rfcbot resolve &raw |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
I'm just going to go ahead and cc @rust-lang/wg-unsafe-code-guidelines just in case. This is an FCP-merge with some implication on unsafe guidelines. |
For the record I think this stabilization makes sense. It doesn't seem to have many deep implications to me -- it is simply saying that one can construct a slice given a |
It still has some uses though -- you still need the raw methods for potentially dangling or out-of-bounds or NULL or unaligned pointers. That seems like a good enough motivation to me. |
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. |
@bors r+ |
📌 Commit 1c0d485 has been approved by |
Stabilize ptr::slice_from_raw_parts[_mut] Closes #36925, the tracking issue. Initial impl: #60667 r? @rust-lang/libs In addition to stabilizing, I've adjusted the example of `ptr::slice_from_raw_parts` to use `slice_from_raw_parts` instead of `slice_from_raw_parts_mut`, which was unnecessary for the example as written.
☀️ Test successful - checks-azure |
Closes #36925, the tracking issue.
Initial impl: #60667
r? @rust-lang/libs
In addition to stabilizing, I've adjusted the example of
ptr::slice_from_raw_parts
to useslice_from_raw_parts
instead ofslice_from_raw_parts_mut
, which was unnecessary for the example as written.