-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Tracking Issue for raw slice len() method (slice_ptr_len, const_slice_ptr_len) #71146
Comments
PR #71940 adds |
This follows the precedent of the recently-added `<*const [T]>::len` (adding to its tracking issue rust-lang#71146) and `ptr::slice_from_raw_parts`.
Add `len` and `slice_from_raw_parts` to `NonNull<[T]>` This follows the precedent of the recently-added `<*const [T]>::len` (adding to its tracking issue rust-lang#71146) and `ptr::slice_from_raw_parts`.
#73987 is a potential blocker for stabilization of these methods. |
Is it really? I feel that a DST struct with a slice field is not a common case, and certainly not the only one. |
That issue shows a general problem with methods where |
This does look like a footgun, but I think the core of that issue is not at all the Once you do have a |
(Responded there. What you describe is buggy behavior, IMO -- the source code didn't involve a |
add (unchecked) indexing methods to raw (and NonNull) slices This complements the existing (unstable) `len` method. Unfortunately, for non-null slices, we cannot call this method `as_ptr` as that overlaps with the existing method of the same name. If this looks reasonable to accept, I propose to reuse the rust-lang#71146 tracking issue and rename the feature get to `slice_ptr_methods` or so. Cc @SimonSapin Fixes rust-lang#60639
add (unchecked) indexing methods to raw (and NonNull) slices This complements the existing (unstable) `len` method. Unfortunately, for non-null slices, we cannot call this method `as_ptr` as that overlaps with the existing method of the same name. If this looks reasonable to accept, I propose to reuse the rust-lang#71146 tracking issue and rename the feature get to `slice_ptr_methods` or so. Cc @SimonSapin Fixes rust-lang#60639
add (unchecked) indexing methods to raw (and NonNull) slices This complements the existing (unstable) `len` method. Unfortunately, for non-null slices, we cannot call this method `as_ptr` as that overlaps with the existing method of the same name. If this looks reasonable to accept, I propose to reuse the rust-lang#71146 tracking issue and rename the feature get to `slice_ptr_methods` or so. Cc @SimonSapin Fixes rust-lang#60639
add (unchecked) indexing methods to raw (and NonNull) slices This complements the existing (unstable) `len` method. Unfortunately, for non-null slices, we cannot call this method `as_ptr` as that overlaps with the existing method of the same name. If this looks reasonable to accept, I propose to reuse the rust-lang#71146 tracking issue and rename the feature get to `slice_ptr_methods` or so. Cc @SimonSapin Fixes rust-lang#60639
add (unchecked) indexing methods to raw (and NonNull) slices This complements the existing (unstable) `len` method. Unfortunately, for non-null slices, we cannot call this method `as_ptr` as that overlaps with the existing method of the same name. If this looks reasonable to accept, I propose to reuse the rust-lang#71146 tracking issue and rename the feature get to `slice_ptr_methods` or so. Cc @SimonSapin Fixes rust-lang#60639
add (unchecked) indexing methods to raw (and NonNull) slices This complements the existing (unstable) `len` method. Unfortunately, for non-null slices, we cannot call this method `as_ptr` as that overlaps with the existing method of the same name. If this looks reasonable to accept, I propose to reuse the rust-lang#71146 tracking issue and rename the feature get to `slice_ptr_methods` or so. Cc @SimonSapin Fixes rust-lang#60639
add (unchecked) indexing methods to raw (and NonNull) slices This complements the existing (unstable) `len` method. Unfortunately, for non-null slices, we cannot call this method `as_ptr` as that overlaps with the existing method of the same name. If this looks reasonable to accept, I propose to reuse the rust-lang#71146 tracking issue and rename the feature get to `slice_ptr_methods` or so. Cc @SimonSapin Fixes rust-lang#60639
Hello everyone. Thank you for working on this feature! I understand that currently #73987 is a blocker for |
A second idea for a suggestion that came to me today. Currently this tracking issues is for all of |
#73987 indeed does not affect |
That's a good point. It should be added as well for consistency with raw pointers. |
As per #122800 (comment), #122800 currently uses this issue as the tracking issue for |
Adding something to FCP after the boxes were already checked is rather unconventional (I expected a new tracking issue for a new function) -- @rust-lang/libs-api I hope you're okay with it (a team member proposed to do this after all). |
I've added I'll restart the FCP to make sure everyone is aware of the change. @rfcbot fcp cancel |
@Amanieu proposal cancelled. |
@rfcbot fcp merge |
Team member @Amanieu 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. 🔔 |
…Amanieu Add `NonNull::<[T]>::is_empty`. As per rust-lang#71146 (comment) I figured this should be fine to be insta-stable (with an FCP), but I can edit if that is not desired. r? `@Amanieu`
…Amanieu Add `NonNull::<[T]>::is_empty`. As per rust-lang#71146 (comment) I figured this should be fine to be insta-stable (with an FCP), but I can edit if that is not desired. r? ``@Amanieu``
…Amanieu Add `NonNull::<[T]>::is_empty`. As per rust-lang#71146 (comment) I figured this should be fine to be insta-stable (with an FCP), but I can edit if that is not desired. r? ```@Amanieu```
Rollup merge of rust-lang#122800 - zachs18:nonnull-slice-is_empty, r=Amanieu Add `NonNull::<[T]>::is_empty`. As per rust-lang#71146 (comment) I figured this should be fine to be insta-stable (with an FCP), but I can edit if that is not desired. r? ```@Amanieu```
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. |
… r=jhpratt Stabilize (const_)slice_ptr_len and (const_)slice_ptr_is_empty_nonnull Stabilized API: ```rust impl<T> *mut [T] { pub const fn len(self) -> usize; pub const fn is_empty(self) -> bool; } impl<T> *const [T] { pub const fn len(self) -> usize; pub const fn is_empty(self) -> bool; } impl<T> NonNull<[T]> { pub const fn is_empty(self) -> bool; } ``` FCP completed in tracking issue: rust-lang#71146
Rollup merge of rust-lang#123868 - eduardosm:stabilize-slice_ptr_len, r=jhpratt Stabilize (const_)slice_ptr_len and (const_)slice_ptr_is_empty_nonnull Stabilized API: ```rust impl<T> *mut [T] { pub const fn len(self) -> usize; pub const fn is_empty(self) -> bool; } impl<T> *const [T] { pub const fn len(self) -> usize; pub const fn is_empty(self) -> bool; } impl<T> NonNull<[T]> { pub const fn is_empty(self) -> bool; } ``` FCP completed in tracking issue: rust-lang#71146
This is a tracking issue for the len() method on raw slice pointers, which allows to get the length of a raw slice pointer when conversion to a slice reference would be UB (because the pointer is null or unaligned).
It covers the feature gates
#![feature(slice_ptr_len)]
and#![feature(const_slice_ptr_len)]
(for const fn).Public API
History / Steps
len
andslice_from_raw_parts
toNonNull<[T]>
#71940*mut [T]
methods #95594NonNull::<[T]>::is_empty
. #122800Open questions
The text was updated successfully, but these errors were encountered: