Add some track_caller info to precondition panics
This commit is contained in:
parent
bbd3a5ada4
commit
e36dc78edd
77 changed files with 175 additions and 207 deletions
|
|
@ -126,6 +126,7 @@ impl Layout {
|
|||
#[rustc_const_stable(feature = "const_alloc_layout_unchecked", since = "1.36.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub const unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self {
|
||||
assert_unsafe_precondition!(
|
||||
check_library_ub,
|
||||
|
|
|
|||
|
|
@ -503,6 +503,7 @@ impl AsciiChar {
|
|||
/// something useful. It might be tightened before stabilization.)
|
||||
#[unstable(feature = "ascii_char", issue = "110998")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub const unsafe fn digit_unchecked(d: u8) -> Self {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ pub(super) const fn from_u32(i: u32) -> Option<char> {
|
|||
#[inline]
|
||||
#[must_use]
|
||||
#[allow(unnecessary_transmutes)]
|
||||
#[track_caller]
|
||||
pub(super) const unsafe fn from_u32_unchecked(i: u32) -> char {
|
||||
// SAFETY: the caller must guarantee that `i` is a valid char value.
|
||||
unsafe {
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ use crate::{intrinsics, ub_checks};
|
|||
#[inline]
|
||||
#[stable(feature = "unreachable", since = "1.27.0")]
|
||||
#[rustc_const_stable(feature = "const_unreachable_unchecked", since = "1.57.0")]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn unreachable_unchecked() -> ! {
|
||||
ub_checks::assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
|
|||
|
|
@ -2634,7 +2634,7 @@ pub const fn three_way_compare<T: Copy>(lhs: T, rhss: T) -> crate::cmp::Ordering
|
|||
#[rustc_const_unstable(feature = "disjoint_bitor", issue = "135758")]
|
||||
#[rustc_nounwind]
|
||||
#[rustc_intrinsic]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
#[miri::intrinsic_fallback_is_spec] // the fallbacks all `assume` to tell Miri
|
||||
pub const unsafe fn disjoint_bitor<T: ~const fallback::DisjointBitOr>(a: T, b: T) -> T {
|
||||
// SAFETY: same preconditions as this function.
|
||||
|
|
|
|||
|
|
@ -555,7 +555,7 @@ macro_rules! int_impl {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn unchecked_add(self, rhs: Self) -> Self {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
@ -705,7 +705,7 @@ macro_rules! int_impl {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn unchecked_sub(self, rhs: Self) -> Self {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
@ -855,7 +855,7 @@ macro_rules! int_impl {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn unchecked_mul(self, rhs: Self) -> Self {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
@ -1199,7 +1199,7 @@ macro_rules! int_impl {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn unchecked_neg(self) -> Self {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
@ -1327,7 +1327,7 @@ macro_rules! int_impl {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn unchecked_shl(self, rhs: u32) -> Self {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
@ -1448,7 +1448,7 @@ macro_rules! int_impl {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn unchecked_shr(self, rhs: u32) -> Self {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
|
|||
|
|
@ -388,6 +388,7 @@ where
|
|||
#[rustc_const_stable(feature = "nonzero", since = "1.28.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub const unsafe fn new_unchecked(n: T) -> Self {
|
||||
match Self::new(n) {
|
||||
Some(n) => n,
|
||||
|
|
@ -428,6 +429,7 @@ where
|
|||
#[unstable(feature = "nonzero_from_mut", issue = "106290")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub unsafe fn from_mut_unchecked(n: &mut T) -> &mut Self {
|
||||
match Self::from_mut(n) {
|
||||
Some(n) => n,
|
||||
|
|
|
|||
|
|
@ -601,7 +601,7 @@ macro_rules! uint_impl {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn unchecked_add(self, rhs: Self) -> Self {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
@ -791,7 +791,7 @@ macro_rules! uint_impl {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn unchecked_sub(self, rhs: Self) -> Self {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
@ -974,7 +974,7 @@ macro_rules! uint_impl {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn unchecked_mul(self, rhs: Self) -> Self {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
@ -1588,7 +1588,7 @@ macro_rules! uint_impl {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn unchecked_shl(self, rhs: u32) -> Self {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
@ -1709,7 +1709,7 @@ macro_rules! uint_impl {
|
|||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn unchecked_shr(self, rhs: u32) -> Self {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ impl IndexRange {
|
|||
/// # Safety
|
||||
/// - `start <= end`
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub(crate) const unsafe fn new_unchecked(start: usize, end: usize) -> Self {
|
||||
ub_checks::assert_unsafe_precondition!(
|
||||
check_library_ub,
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ impl Alignment {
|
|||
/// It must *not* be zero.
|
||||
#[unstable(feature = "ptr_alignment_type", issue = "102070")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub const unsafe fn new_unchecked(align: usize) -> Self {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
|
|||
|
|
@ -444,7 +444,7 @@ impl<T: ?Sized> *const T {
|
|||
#[must_use = "returns a new pointer rather than modifying its argument"]
|
||||
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn offset(self, count: isize) -> *const T
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -497,7 +497,7 @@ impl<T: ?Sized> *const T {
|
|||
#[inline(always)]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn byte_offset(self, count: isize) -> Self {
|
||||
// SAFETY: the caller must uphold the safety contract for `offset`.
|
||||
unsafe { self.cast::<u8>().offset(count).with_metadata_of(self) }
|
||||
|
|
@ -796,7 +796,7 @@ impl<T: ?Sized> *const T {
|
|||
#[stable(feature = "ptr_sub_ptr", since = "1.87.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "1.87.0")]
|
||||
#[inline]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn offset_from_unsigned(self, origin: *const T) -> usize
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -841,7 +841,7 @@ impl<T: ?Sized> *const T {
|
|||
#[stable(feature = "ptr_sub_ptr", since = "1.87.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "1.87.0")]
|
||||
#[inline]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn byte_offset_from_unsigned<U: ?Sized>(self, origin: *const U) -> usize {
|
||||
// SAFETY: the caller must uphold the safety contract for `offset_from_unsigned`.
|
||||
unsafe { self.cast::<u8>().offset_from_unsigned(origin.cast::<u8>()) }
|
||||
|
|
@ -955,7 +955,7 @@ impl<T: ?Sized> *const T {
|
|||
#[must_use = "returns a new pointer rather than modifying its argument"]
|
||||
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn add(self, count: usize) -> Self
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1007,7 +1007,7 @@ impl<T: ?Sized> *const T {
|
|||
#[inline(always)]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn byte_add(self, count: usize) -> Self {
|
||||
// SAFETY: the caller must uphold the safety contract for `add`.
|
||||
unsafe { self.cast::<u8>().add(count).with_metadata_of(self) }
|
||||
|
|
@ -1061,7 +1061,7 @@ impl<T: ?Sized> *const T {
|
|||
#[must_use = "returns a new pointer rather than modifying its argument"]
|
||||
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn sub(self, count: usize) -> Self
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1119,7 +1119,7 @@ impl<T: ?Sized> *const T {
|
|||
#[inline(always)]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn byte_sub(self, count: usize) -> Self {
|
||||
// SAFETY: the caller must uphold the safety contract for `sub`.
|
||||
unsafe { self.cast::<u8>().sub(count).with_metadata_of(self) }
|
||||
|
|
@ -1292,7 +1292,7 @@ impl<T: ?Sized> *const T {
|
|||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_read", since = "1.71.0")]
|
||||
#[inline]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn read(self) -> T
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1313,7 +1313,7 @@ impl<T: ?Sized> *const T {
|
|||
/// [`ptr::read_volatile`]: crate::ptr::read_volatile()
|
||||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||
#[inline]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub unsafe fn read_volatile(self) -> T
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1333,7 +1333,7 @@ impl<T: ?Sized> *const T {
|
|||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_read", since = "1.71.0")]
|
||||
#[inline]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn read_unaligned(self) -> T
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1353,7 +1353,7 @@ impl<T: ?Sized> *const T {
|
|||
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0")]
|
||||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||
#[inline]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn copy_to(self, dest: *mut T, count: usize)
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1373,7 +1373,7 @@ impl<T: ?Sized> *const T {
|
|||
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0")]
|
||||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||
#[inline]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
|
||||
where
|
||||
T: Sized,
|
||||
|
|
|
|||
|
|
@ -1377,6 +1377,7 @@ pub const unsafe fn swap<T>(x: *mut T, y: *mut T) {
|
|||
#[rustc_const_stable(feature = "const_swap_nonoverlapping", since = "1.88.0")]
|
||||
#[rustc_diagnostic_item = "ptr_swap_nonoverlapping"]
|
||||
#[rustc_allow_const_fn_unstable(const_eval_select)] // both implementations behave the same
|
||||
#[track_caller]
|
||||
pub const unsafe fn swap_nonoverlapping<T>(x: *mut T, y: *mut T, count: usize) {
|
||||
ub_checks::assert_unsafe_precondition!(
|
||||
check_library_ub,
|
||||
|
|
@ -1557,6 +1558,7 @@ unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, bytes: NonZero<usize
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_replace", since = "1.83.0")]
|
||||
#[rustc_diagnostic_item = "ptr_replace"]
|
||||
#[track_caller]
|
||||
pub const unsafe fn replace<T>(dst: *mut T, src: T) -> T {
|
||||
// SAFETY: the caller must guarantee that `dst` is valid to be
|
||||
// cast to a mutable reference (valid for writes, aligned, initialized),
|
||||
|
|
@ -1684,7 +1686,7 @@ pub const unsafe fn replace<T>(dst: *mut T, src: T) -> T {
|
|||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_read", since = "1.71.0")]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
#[rustc_diagnostic_item = "ptr_read"]
|
||||
pub const unsafe fn read<T>(src: *const T) -> T {
|
||||
// It would be semantically correct to implement this via `copy_nonoverlapping`
|
||||
|
|
@ -1802,7 +1804,7 @@ pub const unsafe fn read<T>(src: *const T) -> T {
|
|||
#[inline]
|
||||
#[stable(feature = "ptr_unaligned", since = "1.17.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_read", since = "1.71.0")]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
#[rustc_diagnostic_item = "ptr_read_unaligned"]
|
||||
pub const unsafe fn read_unaligned<T>(src: *const T) -> T {
|
||||
let mut tmp = MaybeUninit::<T>::uninit();
|
||||
|
|
@ -1901,7 +1903,7 @@ pub const unsafe fn read_unaligned<T>(src: *const T) -> T {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_write", since = "1.83.0")]
|
||||
#[rustc_diagnostic_item = "ptr_write"]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn write<T>(dst: *mut T, src: T) {
|
||||
// Semantically, it would be fine for this to be implemented as a
|
||||
// `copy_nonoverlapping` and appropriate drop suppression of `src`.
|
||||
|
|
@ -2005,7 +2007,7 @@ pub const unsafe fn write<T>(dst: *mut T, src: T) {
|
|||
#[stable(feature = "ptr_unaligned", since = "1.17.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_write", since = "1.83.0")]
|
||||
#[rustc_diagnostic_item = "ptr_write_unaligned"]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
|
||||
// SAFETY: the caller must guarantee that `dst` is valid for writes.
|
||||
// `dst` cannot overlap `src` because the caller has mutable access
|
||||
|
|
@ -2079,7 +2081,7 @@ pub const unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
|
|||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "volatile", since = "1.9.0")]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
#[rustc_diagnostic_item = "ptr_read_volatile"]
|
||||
pub unsafe fn read_volatile<T>(src: *const T) -> T {
|
||||
// SAFETY: the caller must uphold the safety contract for `volatile_load`.
|
||||
|
|
@ -2160,7 +2162,7 @@ pub unsafe fn read_volatile<T>(src: *const T) -> T {
|
|||
#[inline]
|
||||
#[stable(feature = "volatile", since = "1.9.0")]
|
||||
#[rustc_diagnostic_item = "ptr_write_volatile"]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub unsafe fn write_volatile<T>(dst: *mut T, src: T) {
|
||||
// SAFETY: the caller must uphold the safety contract for `volatile_store`.
|
||||
unsafe {
|
||||
|
|
|
|||
|
|
@ -440,7 +440,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[must_use = "returns a new pointer rather than modifying its argument"]
|
||||
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn offset(self, count: isize) -> *mut T
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -495,7 +495,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[inline(always)]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn byte_offset(self, count: isize) -> Self {
|
||||
// SAFETY: the caller must uphold the safety contract for `offset`.
|
||||
unsafe { self.cast::<u8>().offset(count).with_metadata_of(self) }
|
||||
|
|
@ -970,7 +970,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[stable(feature = "ptr_sub_ptr", since = "1.87.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "1.87.0")]
|
||||
#[inline]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn offset_from_unsigned(self, origin: *const T) -> usize
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -992,7 +992,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[stable(feature = "ptr_sub_ptr", since = "1.87.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "1.87.0")]
|
||||
#[inline]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn byte_offset_from_unsigned<U: ?Sized>(self, origin: *mut U) -> usize {
|
||||
// SAFETY: the caller must uphold the safety contract for `byte_offset_from_unsigned`.
|
||||
unsafe { (self as *const T).byte_offset_from_unsigned(origin) }
|
||||
|
|
@ -1046,7 +1046,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[must_use = "returns a new pointer rather than modifying its argument"]
|
||||
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn add(self, count: usize) -> Self
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1098,7 +1098,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[inline(always)]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn byte_add(self, count: usize) -> Self {
|
||||
// SAFETY: the caller must uphold the safety contract for `add`.
|
||||
unsafe { self.cast::<u8>().add(count).with_metadata_of(self) }
|
||||
|
|
@ -1152,7 +1152,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[must_use = "returns a new pointer rather than modifying its argument"]
|
||||
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn sub(self, count: usize) -> Self
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1210,7 +1210,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[inline(always)]
|
||||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")]
|
||||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn byte_sub(self, count: usize) -> Self {
|
||||
// SAFETY: the caller must uphold the safety contract for `sub`.
|
||||
unsafe { self.cast::<u8>().sub(count).with_metadata_of(self) }
|
||||
|
|
@ -1377,7 +1377,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_read", since = "1.71.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn read(self) -> T
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1398,7 +1398,7 @@ impl<T: ?Sized> *mut T {
|
|||
/// [`ptr::read_volatile`]: crate::ptr::read_volatile()
|
||||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub unsafe fn read_volatile(self) -> T
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1418,7 +1418,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_read", since = "1.71.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn read_unaligned(self) -> T
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1438,7 +1438,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0")]
|
||||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn copy_to(self, dest: *mut T, count: usize)
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1458,7 +1458,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0")]
|
||||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1478,7 +1478,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0")]
|
||||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn copy_from(self, src: *const T, count: usize)
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1498,7 +1498,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0")]
|
||||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize)
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1528,7 +1528,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_write", since = "1.83.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn write(self, val: T)
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1547,7 +1547,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_write", since = "1.83.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn write_bytes(self, val: u8, count: usize)
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1568,7 +1568,7 @@ impl<T: ?Sized> *mut T {
|
|||
/// [`ptr::write_volatile`]: crate::ptr::write_volatile()
|
||||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub unsafe fn write_volatile(self, val: T)
|
||||
where
|
||||
T: Sized,
|
||||
|
|
@ -1588,7 +1588,7 @@ impl<T: ?Sized> *mut T {
|
|||
#[stable(feature = "pointer_methods", since = "1.26.0")]
|
||||
#[rustc_const_stable(feature = "const_ptr_write", since = "1.83.0")]
|
||||
#[inline(always)]
|
||||
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
|
||||
#[track_caller]
|
||||
pub const unsafe fn write_unaligned(self, val: T)
|
||||
where
|
||||
T: Sized,
|
||||
|
|
|
|||
|
|
@ -216,6 +216,7 @@ impl<T: ?Sized> NonNull<T> {
|
|||
#[stable(feature = "nonnull", since = "1.25.0")]
|
||||
#[rustc_const_stable(feature = "const_nonnull_new_unchecked", since = "1.25.0")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub const unsafe fn new_unchecked(ptr: *mut T) -> Self {
|
||||
// SAFETY: the caller must guarantee that `ptr` is non-null.
|
||||
unsafe {
|
||||
|
|
|
|||
|
|
@ -239,6 +239,7 @@ unsafe impl<T> SliceIndex<[T]> for usize {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
unsafe fn get_unchecked(self, slice: *const [T]) -> *const T {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
@ -258,6 +259,7 @@ unsafe impl<T> SliceIndex<[T]> for usize {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut T {
|
||||
assert_unsafe_precondition!(
|
||||
check_library_ub,
|
||||
|
|
@ -307,6 +309,7 @@ unsafe impl<T> SliceIndex<[T]> for ops::IndexRange {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T] {
|
||||
assert_unsafe_precondition!(
|
||||
check_library_ub,
|
||||
|
|
@ -321,6 +324,7 @@ unsafe impl<T> SliceIndex<[T]> for ops::IndexRange {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T] {
|
||||
assert_unsafe_precondition!(
|
||||
check_library_ub,
|
||||
|
|
@ -386,6 +390,7 @@ unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T] {
|
||||
assert_unsafe_precondition!(
|
||||
check_library_ub,
|
||||
|
|
@ -410,6 +415,7 @@ unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T] {
|
||||
assert_unsafe_precondition!(
|
||||
check_library_ub,
|
||||
|
|
|
|||
|
|
@ -631,6 +631,7 @@ impl<T> [T] {
|
|||
#[rustc_no_implicit_autorefs]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[track_caller]
|
||||
pub unsafe fn get_unchecked<I>(&self, index: I) -> &I::Output
|
||||
where
|
||||
I: SliceIndex<Self>,
|
||||
|
|
@ -674,6 +675,7 @@ impl<T> [T] {
|
|||
#[rustc_no_implicit_autorefs]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[track_caller]
|
||||
pub unsafe fn get_unchecked_mut<I>(&mut self, index: I) -> &mut I::Output
|
||||
where
|
||||
I: SliceIndex<Self>,
|
||||
|
|
@ -935,6 +937,7 @@ impl<T> [T] {
|
|||
/// [`swap`]: slice::swap
|
||||
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
|
||||
#[unstable(feature = "slice_swap_unchecked", issue = "88539")]
|
||||
#[track_caller]
|
||||
pub const unsafe fn swap_unchecked(&mut self, a: usize, b: usize) {
|
||||
assert_unsafe_precondition!(
|
||||
check_library_ub,
|
||||
|
|
@ -1307,6 +1310,7 @@ impl<T> [T] {
|
|||
#[rustc_const_stable(feature = "slice_as_chunks", since = "1.88.0")]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[track_caller]
|
||||
pub const unsafe fn as_chunks_unchecked<const N: usize>(&self) -> &[[T; N]] {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
@ -1502,6 +1506,7 @@ impl<T> [T] {
|
|||
#[rustc_const_stable(feature = "slice_as_chunks", since = "1.88.0")]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[track_caller]
|
||||
pub const unsafe fn as_chunks_unchecked_mut<const N: usize>(&mut self) -> &mut [[T; N]] {
|
||||
assert_unsafe_precondition!(
|
||||
check_language_ub,
|
||||
|
|
@ -2061,6 +2066,7 @@ impl<T> [T] {
|
|||
#[rustc_const_stable(feature = "const_slice_split_at_unchecked", since = "1.77.0")]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[track_caller]
|
||||
pub const unsafe fn split_at_unchecked(&self, mid: usize) -> (&[T], &[T]) {
|
||||
// FIXME(const-hack): the const function `from_raw_parts` is used to make this
|
||||
// function const; previously the implementation used
|
||||
|
|
@ -2114,6 +2120,7 @@ impl<T> [T] {
|
|||
#[rustc_const_stable(feature = "const_slice_split_at_mut", since = "1.83.0")]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[track_caller]
|
||||
pub const unsafe fn split_at_mut_unchecked(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
|
||||
let len = self.len();
|
||||
let ptr = self.as_mut_ptr();
|
||||
|
|
@ -4642,6 +4649,7 @@ impl<T> [T] {
|
|||
/// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
|
||||
#[stable(feature = "get_many_mut", since = "1.86.0")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub unsafe fn get_disjoint_unchecked_mut<I, const N: usize>(
|
||||
&mut self,
|
||||
indices: [I; N],
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ use crate::{array, ptr, ub_checks};
|
|||
#[rustc_const_stable(feature = "const_slice_from_raw_parts", since = "1.64.0")]
|
||||
#[must_use]
|
||||
#[rustc_diagnostic_item = "slice_from_raw_parts"]
|
||||
#[track_caller]
|
||||
pub const unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] {
|
||||
// SAFETY: the caller must uphold the safety contract for `from_raw_parts`.
|
||||
unsafe {
|
||||
|
|
@ -174,6 +175,7 @@ pub const unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T]
|
|||
#[rustc_const_stable(feature = "const_slice_from_raw_parts_mut", since = "1.83.0")]
|
||||
#[must_use]
|
||||
#[rustc_diagnostic_item = "slice_from_raw_parts_mut"]
|
||||
#[track_caller]
|
||||
pub const unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T] {
|
||||
// SAFETY: the caller must uphold the safety contract for `from_raw_parts_mut`.
|
||||
unsafe {
|
||||
|
|
@ -270,6 +272,7 @@ pub const fn from_mut<T>(s: &mut T) -> &mut [T] {
|
|||
/// [valid]: ptr#safety
|
||||
#[unstable(feature = "slice_from_ptr_range", issue = "89792")]
|
||||
#[rustc_const_unstable(feature = "const_slice_from_ptr_range", issue = "89792")]
|
||||
#[track_caller]
|
||||
pub const unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] {
|
||||
// SAFETY: the caller must uphold the safety contract for `from_ptr_range`.
|
||||
unsafe { from_raw_parts(range.start, range.end.offset_from_unsigned(range.start)) }
|
||||
|
|
|
|||
|
|
@ -186,6 +186,7 @@ unsafe impl SliceIndex<str> for ops::Range<usize> {
|
|||
}
|
||||
}
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
unsafe fn get_unchecked(self, slice: *const str) -> *const Self::Output {
|
||||
let slice = slice as *const [u8];
|
||||
|
||||
|
|
@ -213,6 +214,7 @@ unsafe impl SliceIndex<str> for ops::Range<usize> {
|
|||
}
|
||||
}
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
unsafe fn get_unchecked_mut(self, slice: *mut str) -> *mut Self::Output {
|
||||
let slice = slice as *mut [u8];
|
||||
|
||||
|
|
@ -288,6 +290,7 @@ unsafe impl SliceIndex<str> for range::Range<usize> {
|
|||
}
|
||||
}
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
unsafe fn get_unchecked(self, slice: *const str) -> *const Self::Output {
|
||||
let slice = slice as *const [u8];
|
||||
|
||||
|
|
@ -315,6 +318,7 @@ unsafe impl SliceIndex<str> for range::Range<usize> {
|
|||
}
|
||||
}
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
unsafe fn get_unchecked_mut(self, slice: *mut str) -> *mut Self::Output {
|
||||
let slice = slice as *mut [u8];
|
||||
|
||||
|
|
|
|||
|
|
@ -63,11 +63,13 @@ macro_rules! assert_unsafe_precondition {
|
|||
#[rustc_no_mir_inline]
|
||||
#[inline]
|
||||
#[rustc_nounwind]
|
||||
#[track_caller]
|
||||
const fn precondition_check($($name:$ty),*) {
|
||||
if !$e {
|
||||
::core::panicking::panic_nounwind(concat!("unsafe precondition(s) violated: ", $message,
|
||||
let msg = concat!("unsafe precondition(s) violated: ", $message,
|
||||
"\n\nThis indicates a bug in the program. \
|
||||
This Undefined Behavior check is optional, and cannot be relied on for safety."));
|
||||
This Undefined Behavior check is optional, and cannot be relied on for safety.");
|
||||
::core::panicking::panic_nounwind_fmt(::core::fmt::Arguments::new_const(&[msg]), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC:
|
||||
thread 'main' panicked at tests/fail/ptr_swap_nonoverlapping.rs:LL:CC:
|
||||
unsafe precondition(s) violated: ptr::swap_nonoverlapping requires that both pointer arguments are aligned and non-null and the specified memory ranges do not overlap
|
||||
|
||||
This indicates a bug in the program. This Undefined Behavior check is optional, and cannot be relied on for safety.
|
||||
|
|
@ -18,9 +18,6 @@ LL | ABORT()
|
|||
= note: inside closure at RUSTLIB/std/src/panicking.rs:LL:CC
|
||||
= note: inside `std::sys::backtrace::__rust_end_short_backtrace::<{closure@std::panicking::begin_panic_handler::{closure#0}}, !>` at RUSTLIB/std/src/sys/backtrace.rs:LL:CC
|
||||
= note: inside `std::panicking::begin_panic_handler` at RUSTLIB/std/src/panicking.rs:LL:CC
|
||||
= note: inside `core::panicking::panic_nounwind` at RUSTLIB/core/src/panicking.rs:LL:CC
|
||||
= note: inside `std::ptr::swap_nonoverlapping::precondition_check` at RUSTLIB/core/src/ub_checks.rs:LL:CC
|
||||
= note: inside `std::ptr::swap_nonoverlapping::<usize>` at RUSTLIB/core/src/ub_checks.rs:LL:CC
|
||||
note: inside `main`
|
||||
--> tests/fail/ptr_swap_nonoverlapping.rs:LL:CC
|
||||
|
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
scope 10 (inlined <std::alloc::Global as Allocator>::allocate) {
|
||||
}
|
||||
}
|
||||
scope 9 (inlined Layout::from_size_align_unchecked) {
|
||||
scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) {
|
||||
let mut _19: bool;
|
||||
let _20: ();
|
||||
let mut _21: std::ptr::Alignment;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
scope 10 (inlined <std::alloc::Global as Allocator>::allocate) {
|
||||
}
|
||||
}
|
||||
scope 9 (inlined Layout::from_size_align_unchecked) {
|
||||
scope 9 (inlined #[track_caller] Layout::from_size_align_unchecked) {
|
||||
let mut _19: bool;
|
||||
let _20: ();
|
||||
let mut _21: std::ptr::Alignment;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
// EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir
|
||||
pub unsafe fn unchecked_shl_unsigned_smaller(a: u16, b: u32) -> u16 {
|
||||
// CHECK-LABEL: fn unchecked_shl_unsigned_smaller(
|
||||
// CHECK: (inlined core::num::<impl u16>::unchecked_shl)
|
||||
// CHECK: (inlined #[track_caller] core::num::<impl u16>::unchecked_shl)
|
||||
a.unchecked_shl(b)
|
||||
}
|
||||
|
||||
|
|
@ -19,6 +19,6 @@ pub unsafe fn unchecked_shl_unsigned_smaller(a: u16, b: u32) -> u16 {
|
|||
// EMIT_MIR unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.mir
|
||||
pub unsafe fn unchecked_shr_signed_bigger(a: i64, b: u32) -> i64 {
|
||||
// CHECK-LABEL: fn unchecked_shr_signed_bigger(
|
||||
// CHECK: (inlined core::num::<impl i64>::unchecked_shr)
|
||||
// CHECK: (inlined #[track_caller] core::num::<impl i64>::unchecked_shr)
|
||||
a.unchecked_shr(b)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
let mut _0: u16;
|
||||
let mut _3: u16;
|
||||
let mut _4: u32;
|
||||
+ scope 1 (inlined core::num::<impl u16>::unchecked_shl) {
|
||||
+ scope 1 (inlined #[track_caller] core::num::<impl u16>::unchecked_shl) {
|
||||
+ let _5: ();
|
||||
+ scope 2 (inlined core::ub_checks::check_language_ub) {
|
||||
+ let mut _6: bool;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
let mut _0: u16;
|
||||
let mut _3: u16;
|
||||
let mut _4: u32;
|
||||
+ scope 1 (inlined core::num::<impl u16>::unchecked_shl) {
|
||||
+ scope 1 (inlined #[track_caller] core::num::<impl u16>::unchecked_shl) {
|
||||
+ let _5: ();
|
||||
+ scope 2 (inlined core::ub_checks::check_language_ub) {
|
||||
+ let mut _6: bool;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 {
|
|||
debug a => _1;
|
||||
debug b => _2;
|
||||
let mut _0: u16;
|
||||
scope 1 (inlined core::num::<impl u16>::unchecked_shl) {
|
||||
scope 1 (inlined #[track_caller] core::num::<impl u16>::unchecked_shl) {
|
||||
scope 2 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 3 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 {
|
|||
debug a => _1;
|
||||
debug b => _2;
|
||||
let mut _0: u16;
|
||||
scope 1 (inlined core::num::<impl u16>::unchecked_shl) {
|
||||
scope 1 (inlined #[track_caller] core::num::<impl u16>::unchecked_shl) {
|
||||
scope 2 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 3 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
let mut _0: i64;
|
||||
let mut _3: i64;
|
||||
let mut _4: u32;
|
||||
+ scope 1 (inlined core::num::<impl i64>::unchecked_shr) {
|
||||
+ scope 1 (inlined #[track_caller] core::num::<impl i64>::unchecked_shr) {
|
||||
+ let _5: ();
|
||||
+ scope 2 (inlined core::ub_checks::check_language_ub) {
|
||||
+ let mut _6: bool;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
let mut _0: i64;
|
||||
let mut _3: i64;
|
||||
let mut _4: u32;
|
||||
+ scope 1 (inlined core::num::<impl i64>::unchecked_shr) {
|
||||
+ scope 1 (inlined #[track_caller] core::num::<impl i64>::unchecked_shr) {
|
||||
+ let _5: ();
|
||||
+ scope 2 (inlined core::ub_checks::check_language_ub) {
|
||||
+ let mut _6: bool;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ fn unchecked_shr_signed_bigger(_1: i64, _2: u32) -> i64 {
|
|||
debug a => _1;
|
||||
debug b => _2;
|
||||
let mut _0: i64;
|
||||
scope 1 (inlined core::num::<impl i64>::unchecked_shr) {
|
||||
scope 1 (inlined #[track_caller] core::num::<impl i64>::unchecked_shr) {
|
||||
scope 2 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 3 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ fn unchecked_shr_signed_bigger(_1: i64, _2: u32) -> i64 {
|
|||
debug a => _1;
|
||||
debug b => _2;
|
||||
let mut _0: i64;
|
||||
scope 1 (inlined core::num::<impl i64>::unchecked_shr) {
|
||||
scope 1 (inlined #[track_caller] core::num::<impl i64>::unchecked_shr) {
|
||||
scope 2 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 3 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
+ let mut _3: isize;
|
||||
+ scope 2 {
|
||||
+ }
|
||||
+ scope 3 (inlined unreachable_unchecked) {
|
||||
+ scope 3 (inlined #[track_caller] unreachable_unchecked) {
|
||||
+ let _4: ();
|
||||
+ scope 4 (inlined core::ub_checks::check_language_ub) {
|
||||
+ let mut _5: bool;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
+ let mut _3: isize;
|
||||
+ scope 2 {
|
||||
+ }
|
||||
+ scope 3 (inlined unreachable_unchecked) {
|
||||
+ scope 3 (inlined #[track_caller] unreachable_unchecked) {
|
||||
+ let _4: ();
|
||||
+ scope 4 (inlined core::ub_checks::check_language_ub) {
|
||||
+ let mut _5: bool;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ fn unwrap_unchecked(_1: Option<T>) -> T {
|
|||
let mut _2: isize;
|
||||
scope 2 {
|
||||
}
|
||||
scope 3 (inlined unreachable_unchecked) {
|
||||
scope 3 (inlined #[track_caller] unreachable_unchecked) {
|
||||
scope 4 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 5 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ fn unwrap_unchecked(_1: Option<T>) -> T {
|
|||
let mut _2: isize;
|
||||
scope 2 {
|
||||
}
|
||||
scope 3 (inlined unreachable_unchecked) {
|
||||
scope 3 (inlined #[track_caller] unreachable_unchecked) {
|
||||
scope 4 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 5 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
let mut _3: isize;
|
||||
scope 2 {
|
||||
}
|
||||
scope 3 (inlined unreachable_unchecked) {
|
||||
scope 3 (inlined #[track_caller] unreachable_unchecked) {
|
||||
let _4: ();
|
||||
scope 4 (inlined core::ub_checks::check_language_ub) {
|
||||
let mut _5: bool;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ fn checked_shl(_1: u32, _2: u32) -> Option<u32> {
|
|||
scope 1 (inlined core::num::<impl u32>::checked_shl) {
|
||||
let mut _3: bool;
|
||||
let mut _4: u32;
|
||||
scope 2 (inlined core::num::<impl u32>::unchecked_shl) {
|
||||
scope 2 (inlined #[track_caller] core::num::<impl u32>::unchecked_shl) {
|
||||
scope 3 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 4 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ fn checked_shl(_1: u32, _2: u32) -> Option<u32> {
|
|||
scope 1 (inlined core::num::<impl u32>::checked_shl) {
|
||||
let mut _3: bool;
|
||||
let mut _4: u32;
|
||||
scope 2 (inlined core::num::<impl u32>::unchecked_shl) {
|
||||
scope 2 (inlined #[track_caller] core::num::<impl u32>::unchecked_shl) {
|
||||
scope 3 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 4 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ fn ub_if_b(_1: Thing) -> Thing {
|
|||
debug t => _1;
|
||||
let mut _0: Thing;
|
||||
let mut _2: isize;
|
||||
scope 1 (inlined unreachable_unchecked) {
|
||||
scope 1 (inlined #[track_caller] unreachable_unchecked) {
|
||||
scope 2 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 3 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ fn int_range(_1: usize, _2: usize) -> () {
|
|||
scope 8 (inlined <usize as Step>::forward_unchecked) {
|
||||
debug start => _11;
|
||||
debug n => const 1_usize;
|
||||
scope 9 (inlined core::num::<impl usize>::unchecked_add) {
|
||||
scope 9 (inlined #[track_caller] core::num::<impl usize>::unchecked_add) {
|
||||
debug self => _11;
|
||||
debug rhs => const 1_usize;
|
||||
scope 10 (inlined core::ub_checks::check_language_ub) {
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ fn demo_byte_add_fat(_1: *const [u32], _2: usize) -> *const [u32] {
|
|||
debug p => _1;
|
||||
debug n => _2;
|
||||
let mut _0: *const [u32];
|
||||
scope 1 (inlined std::ptr::const_ptr::<impl *const [u32]>::byte_add) {
|
||||
scope 1 (inlined #[track_caller] std::ptr::const_ptr::<impl *const [u32]>::byte_add) {
|
||||
let mut _3: *const u8;
|
||||
let mut _4: *const u8;
|
||||
scope 2 (inlined std::ptr::const_ptr::<impl *const [u32]>::cast::<u8>) {
|
||||
}
|
||||
scope 3 (inlined std::ptr::const_ptr::<impl *const u8>::add) {
|
||||
scope 3 (inlined #[track_caller] std::ptr::const_ptr::<impl *const u8>::add) {
|
||||
}
|
||||
scope 4 (inlined std::ptr::const_ptr::<impl *const u8>::with_metadata_of::<[u32]>) {
|
||||
let mut _5: usize;
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ fn demo_byte_add_fat(_1: *const [u32], _2: usize) -> *const [u32] {
|
|||
debug p => _1;
|
||||
debug n => _2;
|
||||
let mut _0: *const [u32];
|
||||
scope 1 (inlined std::ptr::const_ptr::<impl *const [u32]>::byte_add) {
|
||||
scope 1 (inlined #[track_caller] std::ptr::const_ptr::<impl *const [u32]>::byte_add) {
|
||||
let mut _3: *const u8;
|
||||
let mut _4: *const u8;
|
||||
scope 2 (inlined std::ptr::const_ptr::<impl *const [u32]>::cast::<u8>) {
|
||||
}
|
||||
scope 3 (inlined std::ptr::const_ptr::<impl *const u8>::add) {
|
||||
scope 3 (inlined #[track_caller] std::ptr::const_ptr::<impl *const u8>::add) {
|
||||
}
|
||||
scope 4 (inlined std::ptr::const_ptr::<impl *const u8>::with_metadata_of::<[u32]>) {
|
||||
let mut _5: usize;
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ fn demo_byte_add_thin(_1: *const u32, _2: usize) -> *const u32 {
|
|||
debug p => _1;
|
||||
debug n => _2;
|
||||
let mut _0: *const u32;
|
||||
scope 1 (inlined std::ptr::const_ptr::<impl *const u32>::byte_add) {
|
||||
scope 1 (inlined #[track_caller] std::ptr::const_ptr::<impl *const u32>::byte_add) {
|
||||
let mut _3: *const u8;
|
||||
let mut _4: *const u8;
|
||||
scope 2 (inlined std::ptr::const_ptr::<impl *const u32>::cast::<u8>) {
|
||||
}
|
||||
scope 3 (inlined std::ptr::const_ptr::<impl *const u8>::add) {
|
||||
scope 3 (inlined #[track_caller] std::ptr::const_ptr::<impl *const u8>::add) {
|
||||
}
|
||||
scope 4 (inlined std::ptr::const_ptr::<impl *const u8>::with_metadata_of::<u32>) {
|
||||
scope 5 (inlined std::ptr::metadata::<u32>) {
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ fn demo_byte_add_thin(_1: *const u32, _2: usize) -> *const u32 {
|
|||
debug p => _1;
|
||||
debug n => _2;
|
||||
let mut _0: *const u32;
|
||||
scope 1 (inlined std::ptr::const_ptr::<impl *const u32>::byte_add) {
|
||||
scope 1 (inlined #[track_caller] std::ptr::const_ptr::<impl *const u32>::byte_add) {
|
||||
let mut _3: *const u8;
|
||||
let mut _4: *const u8;
|
||||
scope 2 (inlined std::ptr::const_ptr::<impl *const u32>::cast::<u8>) {
|
||||
}
|
||||
scope 3 (inlined std::ptr::const_ptr::<impl *const u8>::add) {
|
||||
scope 3 (inlined #[track_caller] std::ptr::const_ptr::<impl *const u8>::add) {
|
||||
}
|
||||
scope 4 (inlined std::ptr::const_ptr::<impl *const u8>::with_metadata_of::<u32>) {
|
||||
scope 5 (inlined std::ptr::metadata::<u32>) {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
|
|||
let mut _8: u32;
|
||||
scope 6 {
|
||||
scope 8 (inlined <u32 as Step>::forward_unchecked) {
|
||||
scope 9 (inlined core::num::<impl u32>::unchecked_add) {
|
||||
scope 9 (inlined #[track_caller] core::num::<impl u32>::unchecked_add) {
|
||||
scope 10 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 11 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () {
|
|||
let mut _8: u32;
|
||||
scope 6 {
|
||||
scope 8 (inlined <u32 as Step>::forward_unchecked) {
|
||||
scope 9 (inlined core::num::<impl u32>::unchecked_add) {
|
||||
scope 9 (inlined #[track_caller] core::num::<impl u32>::unchecked_add) {
|
||||
scope 10 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 11 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> {
|
|||
let mut _6: u32;
|
||||
scope 3 {
|
||||
scope 5 (inlined <u32 as Step>::forward_unchecked) {
|
||||
scope 6 (inlined core::num::<impl u32>::unchecked_add) {
|
||||
scope 6 (inlined #[track_caller] core::num::<impl u32>::unchecked_add) {
|
||||
scope 7 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 8 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> {
|
|||
let mut _6: u32;
|
||||
scope 3 {
|
||||
scope 5 (inlined <u32 as Step>::forward_unchecked) {
|
||||
scope 6 (inlined core::num::<impl u32>::unchecked_add) {
|
||||
scope 6 (inlined #[track_caller] core::num::<impl u32>::unchecked_add) {
|
||||
scope 7 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 8 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) ->
|
|||
let mut _0: &mut [u32];
|
||||
let mut _3: usize;
|
||||
let mut _4: usize;
|
||||
scope 1 (inlined core::slice::<impl [u32]>::get_unchecked_mut::<std::ops::Range<usize>>) {
|
||||
scope 1 (inlined #[track_caller] core::slice::<impl [u32]>::get_unchecked_mut::<std::ops::Range<usize>>) {
|
||||
let mut _5: *mut [u32];
|
||||
let mut _11: *mut [u32];
|
||||
scope 2 (inlined <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked_mut) {
|
||||
scope 2 (inlined #[track_caller] <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked_mut) {
|
||||
let mut _6: usize;
|
||||
let _7: ();
|
||||
let _8: usize;
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) ->
|
|||
let mut _0: &mut [u32];
|
||||
let mut _3: usize;
|
||||
let mut _4: usize;
|
||||
scope 1 (inlined core::slice::<impl [u32]>::get_unchecked_mut::<std::ops::Range<usize>>) {
|
||||
scope 1 (inlined #[track_caller] core::slice::<impl [u32]>::get_unchecked_mut::<std::ops::Range<usize>>) {
|
||||
let mut _5: *mut [u32];
|
||||
let mut _11: *mut [u32];
|
||||
scope 2 (inlined <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked_mut) {
|
||||
scope 2 (inlined #[track_caller] <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked_mut) {
|
||||
let mut _6: usize;
|
||||
let _7: ();
|
||||
let _8: usize;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range<usize>) -
|
|||
let mut _3: usize;
|
||||
let mut _4: usize;
|
||||
scope 1 (inlined std::ptr::const_ptr::<impl *const [u32]>::get_unchecked::<std::ops::Range<usize>>) {
|
||||
scope 2 (inlined <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked) {
|
||||
scope 2 (inlined #[track_caller] <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked) {
|
||||
let mut _5: usize;
|
||||
let _6: ();
|
||||
let _7: usize;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ fn slice_ptr_get_unchecked_range(_1: *const [u32], _2: std::ops::Range<usize>) -
|
|||
let mut _3: usize;
|
||||
let mut _4: usize;
|
||||
scope 1 (inlined std::ptr::const_ptr::<impl *const [u32]>::get_unchecked::<std::ops::Range<usize>>) {
|
||||
scope 2 (inlined <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked) {
|
||||
scope 2 (inlined #[track_caller] <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked) {
|
||||
let mut _5: usize;
|
||||
let _6: ();
|
||||
let _7: usize;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
|
|||
scope 30 {
|
||||
let _23: usize;
|
||||
scope 31 {
|
||||
scope 34 (inlined core::num::<impl usize>::unchecked_sub) {
|
||||
scope 34 (inlined #[track_caller] core::num::<impl usize>::unchecked_sub) {
|
||||
scope 35 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 36 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
|
|||
}
|
||||
scope 13 (inlined NonNull::<T>::as_ptr) {
|
||||
}
|
||||
scope 14 (inlined std::ptr::mut_ptr::<impl *mut T>::add) {
|
||||
scope 14 (inlined #[track_caller] std::ptr::mut_ptr::<impl *mut T>::add) {
|
||||
}
|
||||
}
|
||||
scope 8 (inlined NonNull::<[T]>::from_ref) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
|
|||
}
|
||||
scope 13 (inlined NonNull::<T>::as_ptr) {
|
||||
}
|
||||
scope 14 (inlined std::ptr::mut_ptr::<impl *mut T>::add) {
|
||||
scope 14 (inlined #[track_caller] std::ptr::mut_ptr::<impl *mut T>::add) {
|
||||
}
|
||||
}
|
||||
scope 8 (inlined NonNull::<[T]>::from_ref) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
|
|||
scope 18 {
|
||||
let _22: usize;
|
||||
scope 19 {
|
||||
scope 22 (inlined core::num::<impl usize>::unchecked_sub) {
|
||||
scope 22 (inlined #[track_caller] core::num::<impl usize>::unchecked_sub) {
|
||||
scope 23 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 24 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
|
|||
}
|
||||
scope 13 (inlined NonNull::<T>::as_ptr) {
|
||||
}
|
||||
scope 14 (inlined std::ptr::mut_ptr::<impl *mut T>::add) {
|
||||
scope 14 (inlined #[track_caller] std::ptr::mut_ptr::<impl *mut T>::add) {
|
||||
}
|
||||
}
|
||||
scope 8 (inlined NonNull::<[T]>::from_ref) {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
|
|||
scope 18 {
|
||||
let _22: usize;
|
||||
scope 19 {
|
||||
scope 22 (inlined core::num::<impl usize>::unchecked_sub) {
|
||||
scope 22 (inlined #[track_caller] core::num::<impl usize>::unchecked_sub) {
|
||||
scope 23 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 24 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () {
|
|||
}
|
||||
scope 13 (inlined NonNull::<T>::as_ptr) {
|
||||
}
|
||||
scope 14 (inlined std::ptr::mut_ptr::<impl *mut T>::add) {
|
||||
scope 14 (inlined #[track_caller] std::ptr::mut_ptr::<impl *mut T>::add) {
|
||||
}
|
||||
}
|
||||
scope 8 (inlined NonNull::<[T]>::from_ref) {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
|
|||
let mut _8: usize;
|
||||
scope 7 {
|
||||
scope 9 (inlined <usize as Step>::forward_unchecked) {
|
||||
scope 10 (inlined core::num::<impl usize>::unchecked_add) {
|
||||
scope 10 (inlined #[track_caller] core::num::<impl usize>::unchecked_add) {
|
||||
scope 11 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 12 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () {
|
|||
let mut _8: usize;
|
||||
scope 7 {
|
||||
scope 9 (inlined <usize as Step>::forward_unchecked) {
|
||||
scope 10 (inlined core::num::<impl usize>::unchecked_add) {
|
||||
scope 10 (inlined #[track_caller] core::num::<impl usize>::unchecked_add) {
|
||||
scope 11 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 12 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
|
|||
}
|
||||
scope 13 (inlined NonNull::<T>::as_ptr) {
|
||||
}
|
||||
scope 14 (inlined std::ptr::mut_ptr::<impl *mut T>::add) {
|
||||
scope 14 (inlined #[track_caller] std::ptr::mut_ptr::<impl *mut T>::add) {
|
||||
}
|
||||
}
|
||||
scope 8 (inlined NonNull::<[T]>::from_ref) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () {
|
|||
}
|
||||
scope 13 (inlined NonNull::<T>::as_ptr) {
|
||||
}
|
||||
scope 14 (inlined std::ptr::mut_ptr::<impl *mut T>::add) {
|
||||
scope 14 (inlined #[track_caller] std::ptr::mut_ptr::<impl *mut T>::add) {
|
||||
}
|
||||
}
|
||||
scope 8 (inlined NonNull::<[T]>::from_ref) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> {
|
|||
scope 3 {
|
||||
let _11: usize;
|
||||
scope 4 {
|
||||
scope 7 (inlined core::num::<impl usize>::unchecked_sub) {
|
||||
scope 7 (inlined #[track_caller] core::num::<impl usize>::unchecked_sub) {
|
||||
scope 8 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 9 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> {
|
|||
scope 3 {
|
||||
let _11: usize;
|
||||
scope 4 {
|
||||
scope 7 (inlined core::num::<impl usize>::unchecked_sub) {
|
||||
scope 7 (inlined #[track_caller] core::num::<impl usize>::unchecked_sub) {
|
||||
scope 8 (inlined core::ub_checks::check_language_ub) {
|
||||
scope 9 (inlined core::ub_checks::check_language_ub::runtime) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
|
|||
}
|
||||
}
|
||||
}
|
||||
scope 12 (inlined std::slice::from_raw_parts::<'_, u8>) {
|
||||
scope 12 (inlined #[track_caller] std::slice::from_raw_parts::<'_, u8>) {
|
||||
debug data => _3;
|
||||
debug len => _4;
|
||||
let _5: *const [u8];
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
|
|||
}
|
||||
}
|
||||
}
|
||||
scope 12 (inlined std::slice::from_raw_parts::<'_, u8>) {
|
||||
scope 12 (inlined #[track_caller] std::slice::from_raw_parts::<'_, u8>) {
|
||||
debug data => _3;
|
||||
debug len => _4;
|
||||
let _5: *const [u8];
|
||||
|
|
|
|||
|
|
@ -104,20 +104,12 @@ error[E0080]: could not evaluate static initializer
|
|||
|
|
||||
LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation panicked: assertion failed: 0 < pointee_size && pointee_size <= isize::MAX as usize
|
||||
|
|
||||
note: inside `from_ptr_range::<'_, ()>`
|
||||
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
||||
note: inside `std::ptr::const_ptr::<impl *const ()>::offset_from_unsigned`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
||||
error[E0080]: could not evaluate static initializer
|
||||
--> $DIR/forbidden_slices.rs:54:25
|
||||
|
|
||||
LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore
|
||||
| ^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC10 which is only 4 bytes from the end of the allocation
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u32>::add`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/forbidden_slices.rs:57:1
|
||||
|
|
@ -170,31 +162,18 @@ error[E0080]: could not evaluate static initializer
|
|||
|
|
||||
LL | from_ptr_range(ptr..ptr.add(1))
|
||||
| ^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC11+0x1 which is only 7 bytes from the end of the allocation
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u64>::add`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
||||
error[E0080]: could not evaluate static initializer
|
||||
--> $DIR/forbidden_slices.rs:85:34
|
||||
|
|
||||
LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation
|
||||
|
|
||||
note: inside `from_ptr_range::<'_, u32>`
|
||||
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
||||
note: inside `std::ptr::const_ptr::<impl *const u32>::offset_from_unsigned`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
||||
error[E0080]: could not evaluate static initializer
|
||||
--> $DIR/forbidden_slices.rs:87:35
|
||||
|
|
||||
LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation
|
||||
|
|
||||
note: inside `from_ptr_range::<'_, u32>`
|
||||
--> $SRC_DIR/core/src/slice/raw.rs:LL:COL
|
||||
note: inside `std::ptr::const_ptr::<impl *const u32>::offset_from_unsigned`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
||||
error: aborting due to 18 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -3,31 +3,18 @@ error[E0080]: evaluation of constant value failed
|
|||
|
|
||||
LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
|
||||
|
|
||||
note: inside `std::ptr::read::<u32>`
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/out_of_bounds_read.rs:10:39
|
||||
|
|
||||
LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
|
||||
| ^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u32>::read`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `std::ptr::read::<u32>`
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/out_of_bounds_read.rs:12:37
|
||||
|
|
||||
LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
|
||||
|
|
||||
note: inside `std::ptr::mut_ptr::<impl *mut u32>::read`
|
||||
--> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
|
||||
note: inside `std::ptr::read::<u32>`
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ const MISALIGNED_COPY: () = unsafe {
|
|||
let mut z = 123;
|
||||
y.copy_to_nonoverlapping(&mut z, 1);
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
//~| NOTE inside `std::ptr::const_ptr
|
||||
//~| NOTE inside `std::ptr::copy_nonoverlapping::<u32>`
|
||||
//~| NOTE accessing memory with alignment 1, but alignment 4 is required
|
||||
// The actual error points into the implementation of `copy_to_nonoverlapping`.
|
||||
|
|
|
|||
|
|
@ -16,19 +16,17 @@ error[E0080]: evaluation of constant value failed
|
|||
LL | y.copy_to_nonoverlapping(&mut z, 1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment 1, but alignment 4 is required
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u32>::copy_to_nonoverlapping`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `std::ptr::copy_nonoverlapping::<u32>`
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/raw-pointer-ub.rs:34:16
|
||||
--> $DIR/raw-pointer-ub.rs:33: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:41:16
|
||||
--> $DIR/raw-pointer-ub.rs:40:16
|
||||
|
|
||||
LL | let _val = *ptr;
|
||||
| ^^^^ memory access failed: attempting to access 8 bytes, but got ALLOC0 which is only 4 bytes from the end of the allocation
|
||||
|
|
|
|||
|
|
@ -153,11 +153,6 @@ error[E0080]: evaluation of constant value failed
|
|||
|
|
||||
LL | ptr.read();
|
||||
| ^^^^^^^^^^ accessing memory based on pointer with alignment 1, but alignment 4 is required
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u32>::read`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `std::ptr::read::<u32>`
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
|
||||
error: aborting due to 15 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,15 @@
|
|||
const unsafe fn foo(x: bool) -> bool {
|
||||
match x {
|
||||
true => true,
|
||||
false => std::hint::unreachable_unchecked(), //~ NOTE inside `foo`
|
||||
false => std::hint::unreachable_unchecked(),
|
||||
//~^ NOTE inside `foo`
|
||||
//~| NOTE the failure occurred here
|
||||
}
|
||||
}
|
||||
|
||||
const BAR: bool = unsafe { foo(false) };
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
//~| NOTE entering unreachable code
|
||||
//~| NOTE inside `unreachable_unchecked`
|
||||
|
||||
fn main() {
|
||||
assert_eq!(BAR, true);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const_unsafe_unreachable_ub.rs:8:28
|
||||
--> $DIR/const_unsafe_unreachable_ub.rs:10:28
|
||||
|
|
||||
LL | const BAR: bool = unsafe { foo(false) };
|
||||
| ^^^^^^^^^^ entering unreachable code
|
||||
|
|
@ -8,9 +8,7 @@ note: inside `foo`
|
|||
--> $DIR/const_unsafe_unreachable_ub.rs:4:18
|
||||
|
|
||||
LL | false => std::hint::unreachable_unchecked(),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: inside `unreachable_unchecked`
|
||||
--> $SRC_DIR/core/src/hint.rs:LL:COL
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,6 @@ error[E0080]: evaluation of constant value failed
|
|||
LL | (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::read`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
note: inside `std::ptr::read::<u8>`
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
= help: this code performed an operation that depends on the underlying bytes representing a pointer
|
||||
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ error[E0080]: evaluation of constant value failed
|
|||
18 | | );
|
||||
| |_________^ unable to copy parts of a pointer from memory at ALLOC0
|
||||
|
|
||||
note: inside `swap_nonoverlapping::<MaybeUninit<u8>>`
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
note: inside `swap_nonoverlapping::compiletime::<MaybeUninit<u8>>`
|
||||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
note: inside `std::ptr::swap_nonoverlapping_const::<MaybeUninit<u8>>`
|
||||
|
|
@ -18,7 +16,6 @@ note: inside `std::ptr::copy_nonoverlapping::<MaybeUninit<u8>>`
|
|||
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
|
||||
= help: this code performed an operation that depends on the underlying bytes representing a pointer
|
||||
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
|
||||
= note: this error originates in the macro `$crate::intrinsics::const_eval_select` which comes from the expansion of the macro `const_eval_select` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -3,99 +3,66 @@ error[E0080]: evaluation of constant value failed
|
|||
|
|
||||
LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC0 which is at the beginning of the allocation
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_ub.rs:9:43
|
||||
|
|
||||
LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC1 which is only 1 byte from the end of the allocation
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_ub.rs:10:45
|
||||
|
|
||||
LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC2 which is only $BYTES bytes from the end of the allocation
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_ub.rs:12:43
|
||||
|
|
||||
LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize`
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u16>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_ub.rs:13:44
|
||||
|
|
||||
LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize`
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u16>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_ub.rs:14:56
|
||||
|
|
||||
LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_ub.rs:15:57
|
||||
|
|
||||
LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_ub.rs:16:49
|
||||
|
|
||||
LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC3-0x2 which is only $BYTES bytes from the beginning of the allocation
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_ub.rs:18:50
|
||||
|
|
||||
LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by 1 byte, but got ALLOC4 which is at or beyond the end of the allocation of size $BYTES bytes
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_ub.rs:19:42
|
||||
|
|
||||
LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
note: inside `std::ptr::mut_ptr::<impl *mut u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/offset_ub.rs:22:47
|
||||
|
|
||||
LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance)
|
||||
|
|
||||
note: inside `std::ptr::const_ptr::<impl *const u8>::offset`
|
||||
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@ note: inside `ub`
|
|||
--> $DIR/interpret-in-promoted.rs:9:5
|
||||
|
|
||||
LL | std::hint::unreachable_unchecked();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: inside `unreachable_unchecked`
|
||||
--> $SRC_DIR/core/src/hint.rs:LL:COL
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/interpret-in-promoted.rs:15:27
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@ note: inside `ub`
|
|||
--> $DIR/interpret-in-promoted.rs:9:5
|
||||
|
|
||||
LL | std::hint::unreachable_unchecked();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: inside `unreachable_unchecked`
|
||||
--> $SRC_DIR/core/src/hint.rs:LL:COL
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the failure occurred here
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/interpret-in-promoted.rs:15:27
|
||||
|
|
|
|||
|
|
@ -1,3 +1,25 @@
|
|||
print-type-size type: `std::fmt::Arguments<'_>`: 48 bytes, alignment: 8 bytes
|
||||
print-type-size field `.pieces`: 16 bytes
|
||||
print-type-size field `.args`: 16 bytes
|
||||
print-type-size field `.fmt`: 16 bytes
|
||||
print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes
|
||||
print-type-size field `.file`: 16 bytes
|
||||
print-type-size field `.line`: 4 bytes
|
||||
print-type-size field `.col`: 4 bytes
|
||||
print-type-size type: `core::fmt::rt::Argument<'_>`: 16 bytes, alignment: 8 bytes
|
||||
print-type-size field `.ty`: 16 bytes
|
||||
print-type-size type: `core::fmt::rt::ArgumentType<'_>`: 16 bytes, alignment: 8 bytes
|
||||
print-type-size variant `Placeholder`: 16 bytes
|
||||
print-type-size field `.value`: 8 bytes
|
||||
print-type-size field `.formatter`: 8 bytes
|
||||
print-type-size field `._lifetime`: 0 bytes
|
||||
print-type-size variant `Count`: 10 bytes
|
||||
print-type-size padding: 8 bytes
|
||||
print-type-size field `.0`: 2 bytes, alignment: 2 bytes
|
||||
print-type-size type: `std::option::Option<&[core::fmt::rt::Placeholder]>`: 16 bytes, alignment: 8 bytes
|
||||
print-type-size variant `Some`: 16 bytes
|
||||
print-type-size field `.0`: 16 bytes
|
||||
print-type-size variant `None`: 0 bytes
|
||||
print-type-size type: `IndirectNonZero`: 12 bytes, alignment: 4 bytes
|
||||
print-type-size field `.nested`: 8 bytes
|
||||
print-type-size field `.post`: 2 bytes
|
||||
|
|
@ -34,6 +56,8 @@ print-type-size field `.val`: 4 bytes
|
|||
print-type-size field `.post`: 2 bytes
|
||||
print-type-size field `.pre`: 1 bytes
|
||||
print-type-size end padding: 1 bytes
|
||||
print-type-size type: `std::ptr::NonNull<()>`: 8 bytes, alignment: 8 bytes
|
||||
print-type-size field `.pointer`: 8 bytes
|
||||
print-type-size type: `Enum4<(), char, (), ()>`: 4 bytes, alignment: 4 bytes
|
||||
print-type-size variant `Two`: 4 bytes
|
||||
print-type-size field `.0`: 4 bytes
|
||||
|
|
@ -116,3 +140,4 @@ print-type-size discriminant: 1 bytes
|
|||
print-type-size variant `Less`: 0 bytes
|
||||
print-type-size variant `Equal`: 0 bytes
|
||||
print-type-size variant `Greater`: 0 bytes
|
||||
print-type-size type: `std::marker::PhantomData<&()>`: 0 bytes, alignment: 1 bytes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue