-
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
Mark {array, slice}::{from_ref, from_mut}
as const fn
#90162
Mark {array, slice}::{from_ref, from_mut}
as const fn
#90162
Conversation
These changes all lgtm. Please add a tracking issue and tests. Once raw ptr deref is stabilized we can immediately ask the libs team for stabilization of the immutable parts |
@oli-obk done. Not sure if the tests make sense, but I've tried 😅 Also, maybe we want to separate features for |
We can just stabilise the immutable functions and leave the gate for the mutable ones. The tests are great @bors r+ |
📌 Commit 5f390cf has been approved by |
…_ref_mut, r=oli-obk Mark `{array, slice}::{from_ref, from_mut}` as const fn This PR marks the following APIs as `const`: ```rust // core::array pub const fn from_ref<T>(s: &T) -> &[T; 1]; pub const fn from_mut<T>(s: &mut T) -> &mut [T; 1]; // core::slice pub const fn from_ref<T>(s: &T) -> &[T]; pub const fn from_mut<T>(s: &mut T) -> &mut [T]; ``` Note that `from_ref` methods require `const_raw_ptr_deref` feature (which seems totally fine, since it's being stabilized, see rust-lang#89551), `from_mut` methods require `const_mut_refs` (which seems fine too since this PR marks `from_mut` functions as const unstable). r? `@oli-obk`
…_ref_mut, r=oli-obk Mark `{array, slice}::{from_ref, from_mut}` as const fn This PR marks the following APIs as `const`: ```rust // core::array pub const fn from_ref<T>(s: &T) -> &[T; 1]; pub const fn from_mut<T>(s: &mut T) -> &mut [T; 1]; // core::slice pub const fn from_ref<T>(s: &T) -> &[T]; pub const fn from_mut<T>(s: &mut T) -> &mut [T]; ``` Note that `from_ref` methods require `const_raw_ptr_deref` feature (which seems totally fine, since it's being stabilized, see rust-lang#89551), `from_mut` methods require `const_mut_refs` (which seems fine too since this PR marks `from_mut` functions as const unstable). r? ``@oli-obk``
…_ref_mut, r=oli-obk Mark `{array, slice}::{from_ref, from_mut}` as const fn This PR marks the following APIs as `const`: ```rust // core::array pub const fn from_ref<T>(s: &T) -> &[T; 1]; pub const fn from_mut<T>(s: &mut T) -> &mut [T; 1]; // core::slice pub const fn from_ref<T>(s: &T) -> &[T]; pub const fn from_mut<T>(s: &mut T) -> &mut [T]; ``` Note that `from_ref` methods require `const_raw_ptr_deref` feature (which seems totally fine, since it's being stabilized, see rust-lang#89551), `from_mut` methods require `const_mut_refs` (which seems fine too since this PR marks `from_mut` functions as const unstable). r? ```@oli-obk```
…askrgr Rollup of 6 pull requests Successful merges: - rust-lang#89558 (Add rustc lint, warning when iterating over hashmaps) - rust-lang#90100 (Skip documentation for tier 2 targets on dist-x86_64-apple-darwin) - rust-lang#90155 (Fix alignment of method headings for scannability) - rust-lang#90162 (Mark `{array, slice}::{from_ref, from_mut}` as const fn) - rust-lang#90221 (Fix ICE when forgetting to `Box` a parameter to a `Self::func` call) - rust-lang#90234 (Temporarily turn overflow checks off for rustc-rayon-core) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This PR marks the following APIs as
const
:Note that
from_ref
methods requireconst_raw_ptr_deref
feature (which seems totally fine, since it's being stabilized, see #89551),from_mut
methods requireconst_mut_refs
(which seems fine too since this PR marksfrom_mut
functions as const unstable).r? @oli-obk