Change:
In stable Rust, the only way to get a with an arbitrary length is through . Unfortunately, that function returns a , which makes it very dubious to use with arbitrary raw pointers.
Given that isn't defined for , what would be the value of being able to create ?
Why would you want one, but also, this seems like it depends on (yet to be decided?) details of the memory model. Is the fleeting moment where a reference exists in enough to invoke UB if the pointer is invalid?
If the reference is , then this is insta-UB for sure.
Is there anything holding [] from stabilizing? If not, I'd like to propose stabilization of these functions, as they are rather simple in concept and allow avoiding manifesting references during (slice) pointer manipulation. cc If I'm reading the various issue threads correctly, the validity invariant of pointer metadata is at max that of the metadata type. For slice pointers, the metadata is typed at . Context: I happen to currently be writing a library that cannot use the reference-based functions, because though the pointers are known to be non-null (and valid), it is not (and cannot be, with the current abstraction) known whether the pointer has unique or shared provenance (thus should use or to be sound). (Specifically, I'm now adding the bits required to handle erasing slice types. I can bifurcate my function into and , but so far, it works fine with one operating over , and it'd be sad to have the / split hanging around even after these functions stabilize (assuming they can)).
I don't recall any reason that cannot be stabilized.
The implementation PR used this feature requested as a tracking issue, but this wasn’t labelled properly. Doing so now.
By the way, would also cover this :)

Discussion:
#![feature(ptr_offset_from)] #![feature(rustc_attrs)] #![feature(receiver_trait)] <del> #![feature(slice_from_raw_parts)] </del> #![feature(specialization)] #![feature(staged_api)] #![feature(std_internals)]

/// # Examples /// /// ```rust <del> /// #![feature(slice_from_raw_parts)] </del> /// use std::ptr; /// /// // create a slice pointer when starting out with a pointer to the first element <del> /// let mut x = [5, 6, 7]; /// let ptr = &mut x[0] as *mut _; /// let slice = ptr::slice_from_raw_parts_mut(ptr, 3); </del> <ins> /// let x = [5, 6, 7]; /// let ptr = x.as_ptr(); /// let slice = ptr::slice_from_raw_parts(ptr, 3); </ins> /// assert_eq!(unsafe { &*slice }[2], 7); /// ``` #[inline] <del> #[unstable(feature = "slice_from_raw_parts", reason = "recently added", issue = "36925")] </del> <ins> #[stable(feature = "slice_from_raw_parts", since = "1.42.0")] </ins> #[rustc_const_unstable(feature = "const_slice_from_raw_parts", issue = "67456")] pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] { unsafe { Repr { raw: FatPtr { data, len } }.rust }

/// [`slice_from_raw_parts`]: fn.slice_from_raw_parts.html /// [`from_raw_parts_mut`]: ../../std/slice/fn.from_raw_parts_mut.html #[inline] <del> #[unstable(feature = "slice_from_raw_parts", reason = "recently added", issue = "36925")] </del> <ins> #[stable(feature = "slice_from_raw_parts", since = "1.42.0")] </ins> #[rustc_const_unstable(feature = "const_slice_from_raw_parts", issue = "67456")] pub const fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] { unsafe { Repr { raw: FatPtr { data, len } }.rust_mut }

#![feature(iter_is_partitioned)] #![feature(iter_order_by)] #![feature(cmp_min_max_by)] <del> #![feature(slice_from_raw_parts)] </del> #![feature(const_slice_from_raw_parts)] #![feature(const_raw_ptr_deref)]