Skip to content

Commit 35446b6

Browse files
committed
Stabilize const versions of ptr::slice_from_raw_parts and slice::from_raw_parts.
1 parent 2184c7c commit 35446b6

File tree

4 files changed

+4
-7
lines changed

4 files changed

+4
-7
lines changed

compiler/rustc_codegen_cranelift/example/issue-91827-extern-types.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// Regression test for issue #91827.
77

88
#![feature(const_ptr_offset_from)]
9-
#![feature(const_slice_from_raw_parts)]
109
#![feature(extern_types)]
1110

1211
use std::ptr::addr_of;

library/core/src/ptr/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ pub const fn null_mut<T>() -> *mut T {
255255
/// ```
256256
#[inline]
257257
#[stable(feature = "slice_from_raw_parts", since = "1.42.0")]
258-
#[rustc_const_unstable(feature = "const_slice_from_raw_parts", issue = "67456")]
258+
#[rustc_const_stable(since = "1.61.0")]
259259
pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
260260
from_raw_parts(data.cast(), len)
261261
}

library/core/src/slice/raw.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ use crate::ptr;
8484
/// [`NonNull::dangling()`]: ptr::NonNull::dangling
8585
#[inline]
8686
#[stable(feature = "rust1", since = "1.0.0")]
87-
#[rustc_const_unstable(feature = "const_slice_from_raw_parts", issue = "67456")]
87+
#[rustc_const_stable(since = "1.61.0")]
8888
pub const unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
8989
debug_check_data_len(data, len);
9090

@@ -133,8 +133,7 @@ pub const unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a m
133133

134134
// In debug builds checks that `data` pointer is aligned and non-null and that slice with given `len` would cover less than half the address space
135135
#[cfg(debug_assertions)]
136-
#[unstable(feature = "const_slice_from_raw_parts", issue = "67456")]
137-
#[rustc_const_unstable(feature = "const_slice_from_raw_parts", issue = "67456")]
136+
#[rustc_const_stable(since = "1.61.0")]
138137
const fn debug_check_data_len<T>(data: *const T, len: usize) {
139138
fn rt_check<T>(data: *const T) {
140139
use crate::intrinsics::is_aligned_and_not_null;
@@ -147,7 +146,7 @@ const fn debug_check_data_len<T>(data: *const T, len: usize) {
147146
// SAFETY:
148147
//
149148
// `rt_check` is just a debug assert to hint users that they are causing UB,
150-
// it is not required for safety (the safety must be guatanteed by
149+
// it is not required for safety (the safety must be guaranteed by
151150
// the `from_raw_parts[_mut]` caller).
152151
//
153152
// As per our safety precondition, we may assume that assertion above never fails.

src/test/ui/consts/const-eval/issue-91827-extern-types.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// Regression test for issue #91827.
55

66
#![feature(const_ptr_offset_from)]
7-
#![feature(const_slice_from_raw_parts)]
87
#![feature(extern_types)]
98

109
use std::ptr::addr_of;

0 commit comments

Comments
 (0)