mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Stabilize [const_]pointer_byte_offsets
This commit is contained in:
parent
cf226e93dc
commit
e36224118f
@ -18,7 +18,6 @@
|
||||
#![feature(new_uninit)]
|
||||
#![feature(maybe_uninit_slice)]
|
||||
#![feature(decl_macro)]
|
||||
#![feature(pointer_byte_offsets)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![cfg_attr(test, feature(test))]
|
||||
#![feature(strict_provenance)]
|
||||
|
@ -141,7 +141,6 @@
|
||||
#![feature(maybe_uninit_uninit_array)]
|
||||
#![feature(maybe_uninit_uninit_array_transpose)]
|
||||
#![feature(pattern)]
|
||||
#![feature(pointer_byte_offsets)]
|
||||
#![feature(ptr_addr_eq)]
|
||||
#![feature(ptr_internals)]
|
||||
#![feature(ptr_metadata)]
|
||||
|
@ -148,7 +148,6 @@
|
||||
#![feature(const_option)]
|
||||
#![feature(const_option_ext)]
|
||||
#![feature(const_pin)]
|
||||
#![feature(const_pointer_byte_offsets)]
|
||||
#![feature(const_pointer_is_aligned)]
|
||||
#![feature(const_ptr_as_ref)]
|
||||
#![feature(const_ptr_is_null)]
|
||||
|
@ -480,8 +480,9 @@ impl<T: ?Sized> *const T {
|
||||
/// leaving the metadata untouched.
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
|
||||
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
pub const unsafe fn byte_offset(self, count: isize) -> Self {
|
||||
// SAFETY: the caller must uphold the safety contract for `offset`.
|
||||
@ -560,8 +561,9 @@ impl<T: ?Sized> *const T {
|
||||
/// leaving the metadata untouched.
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
|
||||
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
||||
pub const fn wrapping_byte_offset(self, count: isize) -> Self {
|
||||
self.cast::<u8>().wrapping_offset(count).with_metadata_of(self)
|
||||
}
|
||||
@ -726,8 +728,9 @@ impl<T: ?Sized> *const T {
|
||||
/// For non-`Sized` pointees this operation considers only the data pointers,
|
||||
/// ignoring the metadata.
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
|
||||
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize {
|
||||
// SAFETY: the caller must uphold the safety contract for `offset_from`.
|
||||
@ -952,8 +955,9 @@ impl<T: ?Sized> *const T {
|
||||
/// leaving the metadata untouched.
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
|
||||
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
pub const unsafe fn byte_add(self, count: usize) -> Self {
|
||||
// SAFETY: the caller must uphold the safety contract for `add`.
|
||||
@ -1045,8 +1049,9 @@ impl<T: ?Sized> *const T {
|
||||
/// leaving the metadata untouched.
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
|
||||
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
pub const unsafe fn byte_sub(self, count: usize) -> Self {
|
||||
// SAFETY: the caller must uphold the safety contract for `sub`.
|
||||
@ -1125,8 +1130,9 @@ impl<T: ?Sized> *const T {
|
||||
/// leaving the metadata untouched.
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
|
||||
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
||||
pub const fn wrapping_byte_add(self, count: usize) -> Self {
|
||||
self.cast::<u8>().wrapping_add(count).with_metadata_of(self)
|
||||
}
|
||||
@ -1203,8 +1209,9 @@ impl<T: ?Sized> *const T {
|
||||
/// leaving the metadata untouched.
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
|
||||
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
||||
pub const fn wrapping_byte_sub(self, count: usize) -> Self {
|
||||
self.cast::<u8>().wrapping_sub(count).with_metadata_of(self)
|
||||
}
|
||||
@ -1372,7 +1379,6 @@ impl<T: ?Sized> *const T {
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(pointer_is_aligned)]
|
||||
/// #![feature(pointer_byte_offsets)]
|
||||
///
|
||||
/// // On some platforms, the alignment of i32 is less than 4.
|
||||
/// #[repr(align(4))]
|
||||
@ -1494,7 +1500,6 @@ impl<T: ?Sized> *const T {
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(pointer_is_aligned)]
|
||||
/// #![feature(pointer_byte_offsets)]
|
||||
///
|
||||
/// // On some platforms, the alignment of i32 is less than 4.
|
||||
/// #[repr(align(4))]
|
||||
|
@ -495,8 +495,9 @@ impl<T: ?Sized> *mut T {
|
||||
/// leaving the metadata untouched.
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
|
||||
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
pub const unsafe fn byte_offset(self, count: isize) -> Self {
|
||||
// SAFETY: the caller must uphold the safety contract for `offset`.
|
||||
@ -574,8 +575,9 @@ impl<T: ?Sized> *mut T {
|
||||
/// leaving the metadata untouched.
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
|
||||
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
||||
pub const fn wrapping_byte_offset(self, count: isize) -> Self {
|
||||
self.cast::<u8>().wrapping_offset(count).with_metadata_of(self)
|
||||
}
|
||||
@ -898,8 +900,9 @@ impl<T: ?Sized> *mut T {
|
||||
/// For non-`Sized` pointees this operation considers only the data pointers,
|
||||
/// ignoring the metadata.
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
|
||||
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
pub const unsafe fn byte_offset_from<U: ?Sized>(self, origin: *const U) -> isize {
|
||||
// SAFETY: the caller must uphold the safety contract for `offset_from`.
|
||||
@ -1053,8 +1056,9 @@ impl<T: ?Sized> *mut T {
|
||||
/// leaving the metadata untouched.
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
|
||||
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
pub const unsafe fn byte_add(self, count: usize) -> Self {
|
||||
// SAFETY: the caller must uphold the safety contract for `add`.
|
||||
@ -1146,8 +1150,9 @@ impl<T: ?Sized> *mut T {
|
||||
/// leaving the metadata untouched.
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
|
||||
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
pub const unsafe fn byte_sub(self, count: usize) -> Self {
|
||||
// SAFETY: the caller must uphold the safety contract for `sub`.
|
||||
@ -1226,8 +1231,9 @@ impl<T: ?Sized> *mut T {
|
||||
/// leaving the metadata untouched.
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
|
||||
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
||||
pub const fn wrapping_byte_add(self, count: usize) -> Self {
|
||||
self.cast::<u8>().wrapping_add(count).with_metadata_of(self)
|
||||
}
|
||||
@ -1304,8 +1310,9 @@ impl<T: ?Sized> *mut T {
|
||||
/// leaving the metadata untouched.
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
|
||||
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_allow_const_fn_unstable(set_ptr_value)]
|
||||
pub const fn wrapping_byte_sub(self, count: usize) -> Self {
|
||||
self.cast::<u8>().wrapping_sub(count).with_metadata_of(self)
|
||||
}
|
||||
@ -1639,7 +1646,6 @@ impl<T: ?Sized> *mut T {
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(pointer_is_aligned)]
|
||||
/// #![feature(pointer_byte_offsets)]
|
||||
///
|
||||
/// // On some platforms, the alignment of i32 is less than 4.
|
||||
/// #[repr(align(4))]
|
||||
@ -1763,7 +1769,6 @@ impl<T: ?Sized> *mut T {
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(pointer_is_aligned)]
|
||||
/// #![feature(pointer_byte_offsets)]
|
||||
///
|
||||
/// // On some platforms, the alignment of i32 is less than 4.
|
||||
/// #[repr(align(4))]
|
||||
|
@ -16,7 +16,6 @@
|
||||
#![feature(const_heap)]
|
||||
#![feature(const_maybe_uninit_as_mut_ptr)]
|
||||
#![feature(const_nonnull_new)]
|
||||
#![feature(const_pointer_byte_offsets)]
|
||||
#![feature(const_pointer_is_aligned)]
|
||||
#![feature(const_ptr_as_ref)]
|
||||
#![feature(const_ptr_write)]
|
||||
@ -87,7 +86,6 @@
|
||||
#![feature(const_waker)]
|
||||
#![feature(never_type)]
|
||||
#![feature(unwrap_infallible)]
|
||||
#![feature(pointer_byte_offsets)]
|
||||
#![feature(pointer_is_aligned)]
|
||||
#![feature(portable_simd)]
|
||||
#![feature(ptr_metadata)]
|
||||
|
@ -331,7 +331,6 @@
|
||||
#![feature(panic_can_unwind)]
|
||||
#![feature(panic_info_message)]
|
||||
#![feature(panic_internals)]
|
||||
#![feature(pointer_byte_offsets)]
|
||||
#![feature(pointer_is_aligned)]
|
||||
#![feature(portable_simd)]
|
||||
#![feature(prelude_2024)]
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(pointer_byte_offsets)]
|
||||
|
||||
fn main() {
|
||||
let v: Vec<u16> = vec![1, 2];
|
||||
// This read is also misaligned. We make sure that the OOB message has priority.
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(pointer_byte_offsets)]
|
||||
|
||||
fn main() {
|
||||
let mut v: Vec<u16> = vec![1, 2];
|
||||
// This read is also misaligned. We make sure that the OOB message has priority.
|
||||
|
@ -1,7 +1,6 @@
|
||||
//@revisions: stack tree
|
||||
//@[tree]compile-flags: -Zmiri-tree-borrows
|
||||
#![feature(strict_provenance)]
|
||||
#![feature(pointer_byte_offsets)]
|
||||
use std::{mem, ptr};
|
||||
|
||||
const PTR_SIZE: usize = mem::size_of::<&i32>();
|
||||
|
@ -2,8 +2,6 @@
|
||||
#![feature(
|
||||
slice_from_ptr_range,
|
||||
const_slice_from_ptr_range,
|
||||
pointer_byte_offsets,
|
||||
const_pointer_byte_offsets
|
||||
)]
|
||||
use std::{
|
||||
mem::MaybeUninit,
|
||||
|
@ -5,8 +5,6 @@
|
||||
#![feature(
|
||||
slice_from_ptr_range,
|
||||
const_slice_from_ptr_range,
|
||||
pointer_byte_offsets,
|
||||
const_pointer_byte_offsets
|
||||
)]
|
||||
use std::{
|
||||
mem::{size_of, MaybeUninit},
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/forbidden_slices.rs:18:1
|
||||
--> $DIR/forbidden_slices.rs:16:1
|
||||
|
|
||||
LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
|
||||
@ -10,7 +10,7 @@ LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/forbidden_slices.rs:20:1
|
||||
--> $DIR/forbidden_slices.rs:18:1
|
||||
|
|
||||
LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
|
||||
@ -21,7 +21,7 @@ LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/forbidden_slices.rs:24:1
|
||||
--> $DIR/forbidden_slices.rs:22:1
|
||||
|
|
||||
LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
|
||||
@ -32,7 +32,7 @@ LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/forbidden_slices.rs:28:1
|
||||
--> $DIR/forbidden_slices.rs:26:1
|
||||
|
|
||||
LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer
|
||||
@ -43,7 +43,7 @@ LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/forbidden_slices.rs:30:1
|
||||
--> $DIR/forbidden_slices.rs:28:1
|
||||
|
|
||||
LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer
|
||||
@ -56,7 +56,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size
|
||||
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/forbidden_slices.rs:32:1
|
||||
--> $DIR/forbidden_slices.rs:30:1
|
||||
|
|
||||
LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
|
||||
@ -67,7 +67,7 @@ LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4)
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/forbidden_slices.rs:35:1
|
||||
--> $DIR/forbidden_slices.rs:33:1
|
||||
|
|
||||
LL | pub static S7: &[u16] = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer
|
||||
@ -78,7 +78,7 @@ LL | pub static S7: &[u16] = unsafe {
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/forbidden_slices.rs:43:1
|
||||
--> $DIR/forbidden_slices.rs:41:1
|
||||
|
|
||||
LL | pub static S8: &[u64] = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
|
||||
@ -98,7 +98,7 @@ note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
|
||||
note: inside `from_ptr_range::<'_, u32>`
|
||||
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
||||
note: inside `R0`
|
||||
--> $DIR/forbidden_slices.rs:50:34
|
||||
--> $DIR/forbidden_slices.rs:48:34
|
||||
|
|
||||
LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -113,7 +113,7 @@ note: inside `ptr::const_ptr::<impl *const ()>::sub_ptr`
|
||||
note: inside `from_ptr_range::<'_, ()>`
|
||||
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
||||
note: inside `R1`
|
||||
--> $DIR/forbidden_slices.rs:51:33
|
||||
--> $DIR/forbidden_slices.rs:49:33
|
||||
|
|
||||
LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -127,13 +127,13 @@ error[E0080]: could not evaluate static initializer
|
||||
note: inside `ptr::const_ptr::<impl *const u32>::add`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `R2`
|
||||
--> $DIR/forbidden_slices.rs:54:25
|
||||
--> $DIR/forbidden_slices.rs:52:25
|
||||
|
|
||||
LL | from_ptr_range(ptr..ptr.add(2))
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/forbidden_slices.rs:56:1
|
||||
--> $DIR/forbidden_slices.rs:54:1
|
||||
|
|
||||
LL | pub static R4: &[u8] = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer
|
||||
@ -144,7 +144,7 @@ LL | pub static R4: &[u8] = unsafe {
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/forbidden_slices.rs:61:1
|
||||
--> $DIR/forbidden_slices.rs:59:1
|
||||
|
|
||||
LL | pub static R5: &[u8] = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer
|
||||
@ -157,7 +157,7 @@ LL | pub static R5: &[u8] = unsafe {
|
||||
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/forbidden_slices.rs:66:1
|
||||
--> $DIR/forbidden_slices.rs:64:1
|
||||
|
|
||||
LL | pub static R6: &[bool] = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
|
||||
@ -168,7 +168,7 @@ LL | pub static R6: &[bool] = unsafe {
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/forbidden_slices.rs:71:1
|
||||
--> $DIR/forbidden_slices.rs:69:1
|
||||
|
|
||||
LL | pub static R7: &[u16] = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
|
||||
@ -186,7 +186,7 @@ error[E0080]: could not evaluate static initializer
|
||||
note: inside `ptr::const_ptr::<impl *const u64>::add`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `R8`
|
||||
--> $DIR/forbidden_slices.rs:78:25
|
||||
--> $DIR/forbidden_slices.rs:76:25
|
||||
|
|
||||
LL | from_ptr_range(ptr..ptr.add(1))
|
||||
| ^^^^^^^^^^
|
||||
@ -201,7 +201,7 @@ note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
|
||||
note: inside `from_ptr_range::<'_, u32>`
|
||||
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
||||
note: inside `R9`
|
||||
--> $DIR/forbidden_slices.rs:83:34
|
||||
--> $DIR/forbidden_slices.rs:81:34
|
||||
|
|
||||
LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -216,7 +216,7 @@ note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr`
|
||||
note: inside `from_ptr_range::<'_, u32>`
|
||||
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
||||
note: inside `R10`
|
||||
--> $DIR/forbidden_slices.rs:84:35
|
||||
--> $DIR/forbidden_slices.rs:82:35
|
||||
|
|
||||
LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -1,5 +1,3 @@
|
||||
#![feature(const_pointer_byte_offsets)]
|
||||
#![feature(pointer_byte_offsets)]
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/raw-pointer-ub.rs:9:16
|
||||
--> $DIR/raw-pointer-ub.rs:7:16
|
||||
|
|
||||
LL | let _val = *ptr;
|
||||
| ^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/raw-pointer-ub.rs:16:5
|
||||
--> $DIR/raw-pointer-ub.rs:14:5
|
||||
|
|
||||
LL | *ptr = 0;
|
||||
| ^^^^^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required
|
||||
@ -20,19 +20,19 @@ note: inside `copy_nonoverlapping::<u32>`
|
||||
note: inside `ptr::const_ptr::<impl *const u32>::copy_to_nonoverlapping`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `MISALIGNED_COPY`
|
||||
--> $DIR/raw-pointer-ub.rs:24:5
|
||||
--> $DIR/raw-pointer-ub.rs:22:5
|
||||
|
|
||||
LL | y.copy_to_nonoverlapping(&mut z, 1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/raw-pointer-ub.rs:36:16
|
||||
--> $DIR/raw-pointer-ub.rs:34:16
|
||||
|
|
||||
LL | let _val = (*ptr).0;
|
||||
| ^^^^^^^^ accessing memory based on pointer with alignment 4, but alignment 16 is required
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/raw-pointer-ub.rs:43:16
|
||||
--> $DIR/raw-pointer-ub.rs:41:16
|
||||
|
|
||||
LL | let _val = *ptr;
|
||||
| ^^^^ memory access failed: ALLOC0 has size 4, so pointer to 8 bytes starting at offset 0 is out-of-bounds
|
||||
|
@ -1,7 +1,7 @@
|
||||
// revisions: no_flag with_flag
|
||||
// [no_flag] check-pass
|
||||
// [with_flag] compile-flags: -Zextra-const-ub-checks
|
||||
#![feature(never_type, pointer_byte_offsets)]
|
||||
#![feature(never_type)]
|
||||
|
||||
use std::mem::transmute;
|
||||
use std::ptr::addr_of;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// compile-flags: -Zunleash-the-miri-inside-of-you
|
||||
#![feature(core_intrinsics, pointer_byte_offsets)]
|
||||
#![feature(core_intrinsics)]
|
||||
|
||||
// During CTFE, we prevent pointer-to-int casts.
|
||||
// Pointer comparisons are prevented in the trait system.
|
||||
|
Loading…
Reference in New Issue
Block a user