-
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
Partially stabilize (const_)slice_ptr_len
feature by stabilizing NonNull::len
#94640
Partially stabilize (const_)slice_ptr_len
feature by stabilizing NonNull::len
#94640
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @yaahc (or someone else) soon. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
f845633
to
9e5d719
Compare
This comment has been minimized.
This comment has been minimized.
9e5d719
to
71ad240
Compare
This comment has been minimized.
This comment has been minimized.
71ad240
to
613f569
Compare
Diff LGTM. Feature is properly split and attributes are correct. cc @oli-obk for the usage of |
@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. |
+1, extremely in favor of this. Thanks for doing the work here @Pointerbender ! |
🔔 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. |
Thank you again @Pointerbender! @bors r+ |
📌 Commit 021a7e4 has been approved by |
Rollup of 5 pull requests Successful merges: - rust-lang#94640 (Partially stabilize `(const_)slice_ptr_len` feature by stabilizing `NonNull::len`) - rust-lang#97034 (Implement `Hash` for `core::alloc::Layout`) - rust-lang#97327 (macros: introduce `fluent_messages` macro ) - rust-lang#97448 (docs: Don't imply that OsStr on Unix is always UTF-8) - rust-lang#97466 ([bootstrap] Move `sanitize_sh` from `dist` to `install`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This PR partially stabilizes features
const_slice_ptr_len
andslice_ptr_len
by only stabilizingNonNull::len
. This partial stabilization is tracked under featuresslice_ptr_len_nonnull
andconst_slice_ptr_len_nonnull
, for which this PR can serve as the tracking issue.To summarize the discussion from #71146 leading up to this partial stabilization request:
It's currently a bit footgunny to obtain the length of a raw slice pointer, stabilization of
NonNull:len
will help with removing these footguns. Some example footguns are:A slightly less complicated version (but still more complicated than it needs to be):
This PR does not stabilize
<*const [T]>::len
and<*mut [T]>::len
because the tracking issue #71146 list a potential blocker for these methods, but this blocker does not apply toNonNull::len
.We should probably also ping the Constant Evaluation WG since this PR includes a
#[rustc_allow_const_fn_unstable(const_slice_ptr_len)]
. My instinct here is that this will probably be okay because the pointer is not actually dereferenced andlen()
does not touch the address component of the pointer, but would be best to double check :)One potential down-side was raised that stabilizing
NonNull::len
could lead to encouragement of coding patterns like:which unnecessarily assert non-nullness. However, these are much less of a footgun than the above examples and this should be resolved when
slice_ptr_len
fully stabilizes eventually.