diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-21 15:29:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-21 15:29:47 +0100 |
| commit | f43ced3dbc3c4563c82bcf807ce8f18061c6b96e (patch) | |
| tree | 0b27abd5f30a000dfd2b42a7d9e0e6673b58e8eb /src/libcore/ptr | |
| parent | a01f956f981d8ab41093d01460d40c17e2b996cc (diff) | |
| parent | 382d370c4f5750900ec8896b3659d7624fe048a0 (diff) | |
Rollup merge of #67462 - DutchGhost:const_slice_from_raw_parts, r=dtolnay
Make ptr::slice_from_raw_parts a const fn available under a feature flag A first step in the direction of https://github.com/rust-lang/rust/issues/67456 . This makes `ptr::slice_from_raw_parts` and `ptr::slice_from_raw_parts_mut` available as a const fn under a feature flag.
Diffstat (limited to 'src/libcore/ptr')
| -rw-r--r-- | src/libcore/ptr/mod.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libcore/ptr/mod.rs b/src/libcore/ptr/mod.rs index a3a73ff6c6c..924563fc44f 100644 --- a/src/libcore/ptr/mod.rs +++ b/src/libcore/ptr/mod.rs @@ -259,7 +259,8 @@ pub(crate) struct FatPtr<T> { /// ``` #[inline] #[unstable(feature = "slice_from_raw_parts", reason = "recently added", issue = "36925")] -pub fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] { +#[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 } } @@ -275,7 +276,8 @@ pub fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] { /// [`from_raw_parts_mut`]: ../../std/slice/fn.from_raw_parts_mut.html #[inline] #[unstable(feature = "slice_from_raw_parts", reason = "recently added", issue = "36925")] -pub fn slice_from_raw_parts_mut<T>(data: *mut T, len: usize) -> *mut [T] { +#[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 } } |
