Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Regression test for issue #91827.

#![feature(const_ptr_offset_from)]
#![feature(const_slice_from_raw_parts)]
#![feature(extern_types)]

use std::ptr::addr_of;
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/ptr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ pub const fn null_mut<T>() -> *mut T {
/// ```
#[inline]
#[stable(feature = "slice_from_raw_parts", since = "1.42.0")]
#[rustc_const_unstable(feature = "const_slice_from_raw_parts", issue = "67456")]
#[rustc_const_stable(since = "1.61.0")]
pub const fn slice_from_raw_parts<T>(data: *const T, len: usize) -> *const [T] {
from_raw_parts(data.cast(), len)
}
Expand Down
7 changes: 3 additions & 4 deletions library/core/src/slice/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ use crate::ptr;
/// [`NonNull::dangling()`]: ptr::NonNull::dangling
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_slice_from_raw_parts", issue = "67456")]
#[rustc_const_stable(since = "1.61.0")]
pub const unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
debug_check_data_len(data, len);

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

// 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
#[cfg(debug_assertions)]
#[unstable(feature = "const_slice_from_raw_parts", issue = "67456")]
#[rustc_const_unstable(feature = "const_slice_from_raw_parts", issue = "67456")]
#[rustc_const_stable(since = "1.61.0")]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Admittedly, this is a change I'm not 100% sure on: its callers are stable in a non-const context, and yet it was marked unstable. I have no real clue what unstable even implies for a non-exported function, so this was mostly a no-thinking-involved mechanical change.

const fn debug_check_data_len<T>(data: *const T, len: usize) {
fn rt_check<T>(data: *const T) {
use crate::intrinsics::is_aligned_and_not_null;
Expand All @@ -147,7 +146,7 @@ const fn debug_check_data_len<T>(data: *const T, len: usize) {
// SAFETY:
//
// `rt_check` is just a debug assert to hint users that they are causing UB,
// it is not required for safety (the safety must be guatanteed by
// it is not required for safety (the safety must be guaranteed by
// the `from_raw_parts[_mut]` caller).
//
// As per our safety precondition, we may assume that assertion above never fails.
Expand Down
1 change: 0 additions & 1 deletion src/test/ui/consts/const-eval/issue-91827-extern-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// Regression test for issue #91827.

#![feature(const_ptr_offset_from)]
#![feature(const_slice_from_raw_parts)]
#![feature(extern_types)]

use std::ptr::addr_of;
Expand Down