Auto merge of #110303 - nbdd0121:master, r=Mark-Simulacrum
Add `debug_assert_nounwind` and convert `assert_unsafe_precondition` `assert_unsafe_precondition` checks non-CTFE-evaluable conditions in runtime and performs no-op in compile time, while many of its current usage can be checked during const eval.
This commit is contained in:
commit
9529a5d265
@ -75,12 +75,12 @@ macro_rules! nonzero_integers {
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const unsafe fn new_unchecked(n: $Int) -> Self {
|
||||
crate::panic::debug_assert_nounwind!(
|
||||
n != 0,
|
||||
concat!(stringify!($Ty), "::new_unchecked requires a non-zero argument")
|
||||
);
|
||||
// SAFETY: this is guaranteed to be safe by the caller.
|
||||
unsafe {
|
||||
core::intrinsics::assert_unsafe_precondition!(
|
||||
concat!(stringify!($Ty), "::new_unchecked requires a non-zero argument"),
|
||||
(n: $Int) => n != 0
|
||||
);
|
||||
Self(n)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::intrinsics::{assert_unsafe_precondition, unchecked_add, unchecked_sub};
|
||||
use crate::intrinsics::{unchecked_add, unchecked_sub};
|
||||
use crate::iter::{FusedIterator, TrustedLen};
|
||||
use crate::num::NonZeroUsize;
|
||||
|
||||
@ -19,13 +19,10 @@ impl IndexRange {
|
||||
/// - `start <= end`
|
||||
#[inline]
|
||||
pub const unsafe fn new_unchecked(start: usize, end: usize) -> Self {
|
||||
// SAFETY: comparisons on usize are pure
|
||||
unsafe {
|
||||
assert_unsafe_precondition!(
|
||||
"IndexRange::new_unchecked requires `start <= end`",
|
||||
(start: usize, end: usize) => start <= end
|
||||
)
|
||||
};
|
||||
crate::panic::debug_assert_nounwind!(
|
||||
start <= end,
|
||||
"IndexRange::new_unchecked requires `start <= end`"
|
||||
);
|
||||
IndexRange { start, end }
|
||||
}
|
||||
|
||||
|
@ -139,6 +139,32 @@ pub macro unreachable_2021 {
|
||||
),
|
||||
}
|
||||
|
||||
/// Asserts that a boolean expression is `true`, and perform a non-unwinding panic otherwise.
|
||||
///
|
||||
/// This macro is similar to `debug_assert!`, but is intended to be used in code that should not
|
||||
/// unwind. For example, checks in `_unchecked` functions that are intended for debugging but should
|
||||
/// not compromise unwind safety.
|
||||
#[doc(hidden)]
|
||||
#[unstable(feature = "core_panic", issue = "none")]
|
||||
#[allow_internal_unstable(core_panic, const_format_args)]
|
||||
#[rustc_macro_transparency = "semitransparent"]
|
||||
pub macro debug_assert_nounwind {
|
||||
($cond:expr $(,)?) => {
|
||||
if $crate::cfg!(debug_assertions) {
|
||||
if !$cond {
|
||||
$crate::panicking::panic_nounwind($crate::concat!("assertion failed: ", $crate::stringify!($cond)));
|
||||
}
|
||||
}
|
||||
},
|
||||
($cond:expr, $($arg:tt)+) => {
|
||||
if $crate::cfg!(debug_assertions) {
|
||||
if !$cond {
|
||||
$crate::panicking::panic_nounwind_fmt($crate::const_format_args!($($arg)+), false);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/// An internal trait used by std to pass data from std to `panic_unwind` and
|
||||
/// other panic runtimes. Not intended to be stabilized any time soon, do not
|
||||
/// use.
|
||||
|
@ -82,28 +82,43 @@ pub const fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! {
|
||||
// and unwinds anyway, we will hit the "unwinding out of nounwind function" guard,
|
||||
// which causes a "panic in a function that cannot unwind".
|
||||
#[rustc_nounwind]
|
||||
pub fn panic_nounwind_fmt(fmt: fmt::Arguments<'_>, force_no_backtrace: bool) -> ! {
|
||||
if cfg!(feature = "panic_immediate_abort") {
|
||||
super::intrinsics::abort()
|
||||
#[rustc_const_unstable(feature = "core_panic", issue = "none")]
|
||||
pub const fn panic_nounwind_fmt(fmt: fmt::Arguments<'_>, force_no_backtrace: bool) -> ! {
|
||||
#[track_caller]
|
||||
fn runtime(fmt: fmt::Arguments<'_>, force_no_backtrace: bool) -> ! {
|
||||
if cfg!(feature = "panic_immediate_abort") {
|
||||
super::intrinsics::abort()
|
||||
}
|
||||
|
||||
// NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call
|
||||
// that gets resolved to the `#[panic_handler]` function.
|
||||
extern "Rust" {
|
||||
#[lang = "panic_impl"]
|
||||
fn panic_impl(pi: &PanicInfo<'_>) -> !;
|
||||
}
|
||||
|
||||
// PanicInfo with the `can_unwind` flag set to false forces an abort.
|
||||
let pi = PanicInfo::internal_constructor(
|
||||
Some(&fmt),
|
||||
Location::caller(),
|
||||
/* can_unwind */ false,
|
||||
force_no_backtrace,
|
||||
);
|
||||
|
||||
// SAFETY: `panic_impl` is defined in safe Rust code and thus is safe to call.
|
||||
unsafe { panic_impl(&pi) }
|
||||
}
|
||||
|
||||
// NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call
|
||||
// that gets resolved to the `#[panic_handler]` function.
|
||||
extern "Rust" {
|
||||
#[lang = "panic_impl"]
|
||||
fn panic_impl(pi: &PanicInfo<'_>) -> !;
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
const fn comptime(fmt: fmt::Arguments<'_>, _force_no_backtrace: bool) -> ! {
|
||||
panic_fmt(fmt);
|
||||
}
|
||||
|
||||
// PanicInfo with the `can_unwind` flag set to false forces an abort.
|
||||
let pi = PanicInfo::internal_constructor(
|
||||
Some(&fmt),
|
||||
Location::caller(),
|
||||
/* can_unwind */ false,
|
||||
force_no_backtrace,
|
||||
);
|
||||
|
||||
// SAFETY: `panic_impl` is defined in safe Rust code and thus is safe to call.
|
||||
unsafe { panic_impl(&pi) }
|
||||
// SAFETY: const panic does not care about unwinding
|
||||
unsafe {
|
||||
super::intrinsics::const_eval_select((fmt, force_no_backtrace), comptime, runtime);
|
||||
}
|
||||
}
|
||||
|
||||
// Next we define a bunch of higher-level wrappers that all bottom out in the two core functions
|
||||
@ -132,7 +147,8 @@ pub const fn panic(expr: &'static str) -> ! {
|
||||
#[cfg_attr(feature = "panic_immediate_abort", inline)]
|
||||
#[lang = "panic_nounwind"] // needed by codegen for non-unwinding panics
|
||||
#[rustc_nounwind]
|
||||
pub fn panic_nounwind(expr: &'static str) -> ! {
|
||||
#[rustc_const_unstable(feature = "core_panic", issue = "none")]
|
||||
pub const fn panic_nounwind(expr: &'static str) -> ! {
|
||||
panic_nounwind_fmt(fmt::Arguments::new_const(&[expr]), /* force_no_backtrace */ false);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
use crate::convert::{TryFrom, TryInto};
|
||||
use crate::intrinsics::assert_unsafe_precondition;
|
||||
use crate::num::NonZeroUsize;
|
||||
use crate::{cmp, fmt, hash, mem, num};
|
||||
|
||||
@ -77,13 +76,10 @@ impl Alignment {
|
||||
#[rustc_const_unstable(feature = "ptr_alignment_type", issue = "102070")]
|
||||
#[inline]
|
||||
pub const unsafe fn new_unchecked(align: usize) -> Self {
|
||||
// SAFETY: Precondition passed to the caller.
|
||||
unsafe {
|
||||
assert_unsafe_precondition!(
|
||||
"Alignment::new_unchecked requires a power of two",
|
||||
(align: usize) => align.is_power_of_two()
|
||||
)
|
||||
};
|
||||
crate::panic::debug_assert_nounwind!(
|
||||
align.is_power_of_two(),
|
||||
"Alignment::new_unchecked requires a power of two"
|
||||
);
|
||||
|
||||
// SAFETY: By precondition, this must be a power of two, and
|
||||
// our variants encompass all possible powers of two.
|
||||
|
@ -1,9 +1,9 @@
|
||||
//! Indexing implementations for `[T]`.
|
||||
|
||||
use crate::intrinsics::assert_unsafe_precondition;
|
||||
use crate::intrinsics::const_eval_select;
|
||||
use crate::intrinsics::unchecked_sub;
|
||||
use crate::ops;
|
||||
use crate::panic::debug_assert_nounwind;
|
||||
use crate::ptr;
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -225,31 +225,25 @@ unsafe impl<T> SliceIndex<[T]> for usize {
|
||||
|
||||
#[inline]
|
||||
unsafe fn get_unchecked(self, slice: *const [T]) -> *const T {
|
||||
let this = self;
|
||||
debug_assert_nounwind!(
|
||||
self < slice.len(),
|
||||
"slice::get_unchecked requires that the index is within the slice",
|
||||
);
|
||||
// SAFETY: the caller guarantees that `slice` is not dangling, so it
|
||||
// cannot be longer than `isize::MAX`. They also guarantee that
|
||||
// `self` is in bounds of `slice` so `self` cannot overflow an `isize`,
|
||||
// so the call to `add` is safe.
|
||||
unsafe {
|
||||
assert_unsafe_precondition!(
|
||||
"slice::get_unchecked requires that the index is within the slice",
|
||||
[T](this: usize, slice: *const [T]) => this < slice.len()
|
||||
);
|
||||
slice.as_ptr().add(self)
|
||||
}
|
||||
unsafe { slice.as_ptr().add(self) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut T {
|
||||
let this = self;
|
||||
debug_assert_nounwind!(
|
||||
self < slice.len(),
|
||||
"slice::get_unchecked_mut requires that the index is within the slice",
|
||||
);
|
||||
// SAFETY: see comments for `get_unchecked` above.
|
||||
unsafe {
|
||||
assert_unsafe_precondition!(
|
||||
"slice::get_unchecked_mut requires that the index is within the slice",
|
||||
[T](this: usize, slice: *mut [T]) => this < slice.len()
|
||||
);
|
||||
slice.as_mut_ptr().add(self)
|
||||
}
|
||||
unsafe { slice.as_mut_ptr().add(self) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -293,32 +287,25 @@ unsafe impl<T> SliceIndex<[T]> for ops::IndexRange {
|
||||
|
||||
#[inline]
|
||||
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T] {
|
||||
let end = self.end();
|
||||
debug_assert_nounwind!(
|
||||
self.end() <= slice.len(),
|
||||
"slice::get_unchecked requires that the index is within the slice"
|
||||
);
|
||||
// SAFETY: the caller guarantees that `slice` is not dangling, so it
|
||||
// cannot be longer than `isize::MAX`. They also guarantee that
|
||||
// `self` is in bounds of `slice` so `self` cannot overflow an `isize`,
|
||||
// so the call to `add` is safe.
|
||||
|
||||
unsafe {
|
||||
assert_unsafe_precondition!(
|
||||
"slice::get_unchecked requires that the index is within the slice",
|
||||
[T](end: usize, slice: *const [T]) => end <= slice.len()
|
||||
);
|
||||
ptr::slice_from_raw_parts(slice.as_ptr().add(self.start()), self.len())
|
||||
}
|
||||
unsafe { ptr::slice_from_raw_parts(slice.as_ptr().add(self.start()), self.len()) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T] {
|
||||
let end = self.end();
|
||||
debug_assert_nounwind!(
|
||||
self.end() <= slice.len(),
|
||||
"slice::get_unchecked_mut requires that the index is within the slice",
|
||||
);
|
||||
// SAFETY: see comments for `get_unchecked` above.
|
||||
unsafe {
|
||||
assert_unsafe_precondition!(
|
||||
"slice::get_unchecked_mut requires that the index is within the slice",
|
||||
[T](end: usize, slice: *mut [T]) => end <= slice.len()
|
||||
);
|
||||
ptr::slice_from_raw_parts_mut(slice.as_mut_ptr().add(self.start()), self.len())
|
||||
}
|
||||
unsafe { ptr::slice_from_raw_parts_mut(slice.as_mut_ptr().add(self.start()), self.len()) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -369,17 +356,15 @@ unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
|
||||
|
||||
#[inline]
|
||||
unsafe fn get_unchecked(self, slice: *const [T]) -> *const [T] {
|
||||
let this = ops::Range { ..self };
|
||||
debug_assert_nounwind!(
|
||||
self.end >= self.start && self.end <= slice.len(),
|
||||
"slice::get_unchecked requires that the range is within the slice",
|
||||
);
|
||||
// SAFETY: the caller guarantees that `slice` is not dangling, so it
|
||||
// cannot be longer than `isize::MAX`. They also guarantee that
|
||||
// `self` is in bounds of `slice` so `self` cannot overflow an `isize`,
|
||||
// so the call to `add` is safe and the length calculation cannot overflow.
|
||||
unsafe {
|
||||
assert_unsafe_precondition!(
|
||||
"slice::get_unchecked requires that the range is within the slice",
|
||||
[T](this: ops::Range<usize>, slice: *const [T]) =>
|
||||
this.end >= this.start && this.end <= slice.len()
|
||||
);
|
||||
let new_len = unchecked_sub(self.end, self.start);
|
||||
ptr::slice_from_raw_parts(slice.as_ptr().add(self.start), new_len)
|
||||
}
|
||||
@ -387,14 +372,12 @@ unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
|
||||
|
||||
#[inline]
|
||||
unsafe fn get_unchecked_mut(self, slice: *mut [T]) -> *mut [T] {
|
||||
let this = ops::Range { ..self };
|
||||
debug_assert_nounwind!(
|
||||
self.end >= self.start && self.end <= slice.len(),
|
||||
"slice::get_unchecked_mut requires that the range is within the slice",
|
||||
);
|
||||
// SAFETY: see comments for `get_unchecked` above.
|
||||
unsafe {
|
||||
assert_unsafe_precondition!(
|
||||
"slice::get_unchecked_mut requires that the range is within the slice",
|
||||
[T](this: ops::Range<usize>, slice: *mut [T]) =>
|
||||
this.end >= this.start && this.end <= slice.len()
|
||||
);
|
||||
let new_len = unchecked_sub(self.end, self.start);
|
||||
ptr::slice_from_raw_parts_mut(slice.as_mut_ptr().add(self.start), new_len)
|
||||
}
|
||||
|
@ -8,13 +8,14 @@
|
||||
|
||||
use crate::cmp::Ordering::{self, Equal, Greater, Less};
|
||||
use crate::fmt;
|
||||
use crate::intrinsics::{assert_unsafe_precondition, exact_div};
|
||||
use crate::intrinsics::exact_div;
|
||||
use crate::marker::Copy;
|
||||
use crate::mem::{self, SizedTypeProperties};
|
||||
use crate::num::NonZeroUsize;
|
||||
use crate::ops::{Bound, FnMut, OneSidedRange, Range, RangeBounds};
|
||||
use crate::option::Option;
|
||||
use crate::option::Option::{None, Some};
|
||||
use crate::panic::debug_assert_nounwind;
|
||||
use crate::ptr;
|
||||
use crate::result::Result;
|
||||
use crate::result::Result::{Err, Ok};
|
||||
@ -929,14 +930,14 @@ impl<T> [T] {
|
||||
#[unstable(feature = "slice_swap_unchecked", issue = "88539")]
|
||||
#[rustc_const_unstable(feature = "const_swap", issue = "83163")]
|
||||
pub const unsafe fn swap_unchecked(&mut self, a: usize, b: usize) {
|
||||
let this = self;
|
||||
let ptr = this.as_mut_ptr();
|
||||
debug_assert_nounwind!(
|
||||
a < self.len() && b < self.len(),
|
||||
"slice::swap_unchecked requires that the indices are within the slice",
|
||||
);
|
||||
|
||||
let ptr = self.as_mut_ptr();
|
||||
// SAFETY: caller has to guarantee that `a < self.len()` and `b < self.len()`
|
||||
unsafe {
|
||||
assert_unsafe_precondition!(
|
||||
"slice::swap_unchecked requires that the indices are within the slice",
|
||||
[T](a: usize, b: usize, this: &mut [T]) => a < this.len() && b < this.len()
|
||||
);
|
||||
ptr::swap(ptr.add(a), ptr.add(b));
|
||||
}
|
||||
}
|
||||
@ -1269,15 +1270,12 @@ impl<T> [T] {
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const unsafe fn as_chunks_unchecked<const N: usize>(&self) -> &[[T; N]] {
|
||||
let this = self;
|
||||
debug_assert_nounwind!(
|
||||
N != 0 && self.len() % N == 0,
|
||||
"slice::as_chunks_unchecked requires `N != 0` and the slice to split exactly into `N`-element chunks",
|
||||
);
|
||||
// SAFETY: Caller must guarantee that `N` is nonzero and exactly divides the slice length
|
||||
let new_len = unsafe {
|
||||
assert_unsafe_precondition!(
|
||||
"slice::as_chunks_unchecked requires `N != 0` and the slice to split exactly into `N`-element chunks",
|
||||
[T](this: &[T], N: usize) => N != 0 && this.len() % N == 0
|
||||
);
|
||||
exact_div(self.len(), N)
|
||||
};
|
||||
let new_len = unsafe { exact_div(self.len(), N) };
|
||||
// SAFETY: We cast a slice of `new_len * N` elements into
|
||||
// a slice of `new_len` many `N` elements chunks.
|
||||
unsafe { from_raw_parts(self.as_ptr().cast(), new_len) }
|
||||
@ -1426,15 +1424,12 @@ impl<T> [T] {
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const unsafe fn as_chunks_unchecked_mut<const N: usize>(&mut self) -> &mut [[T; N]] {
|
||||
let this = &*self;
|
||||
debug_assert_nounwind!(
|
||||
N != 0 && self.len() % N == 0,
|
||||
"slice::as_chunks_unchecked requires `N != 0` and the slice to split exactly into `N`-element chunks",
|
||||
);
|
||||
// SAFETY: Caller must guarantee that `N` is nonzero and exactly divides the slice length
|
||||
let new_len = unsafe {
|
||||
assert_unsafe_precondition!(
|
||||
"slice::as_chunks_unchecked_mut requires `N != 0` and the slice to split exactly into `N`-element chunks",
|
||||
[T](this: &[T], N: usize) => N != 0 && this.len() % N == 0
|
||||
);
|
||||
exact_div(this.len(), N)
|
||||
};
|
||||
let new_len = unsafe { exact_div(self.len(), N) };
|
||||
// SAFETY: We cast a slice of `new_len * N` elements into
|
||||
// a slice of `new_len` many `N` elements chunks.
|
||||
unsafe { from_raw_parts_mut(self.as_mut_ptr().cast(), new_len) }
|
||||
@ -1967,14 +1962,13 @@ impl<T> [T] {
|
||||
let len = self.len();
|
||||
let ptr = self.as_ptr();
|
||||
|
||||
debug_assert_nounwind!(
|
||||
mid <= len,
|
||||
"slice::split_at_unchecked requires the index to be within the slice",
|
||||
);
|
||||
|
||||
// SAFETY: Caller has to check that `0 <= mid <= self.len()`
|
||||
unsafe {
|
||||
assert_unsafe_precondition!(
|
||||
"slice::split_at_unchecked requires the index to be within the slice",
|
||||
(mid: usize, len: usize) => mid <= len
|
||||
);
|
||||
(from_raw_parts(ptr, mid), from_raw_parts(ptr.add(mid), len - mid))
|
||||
}
|
||||
unsafe { (from_raw_parts(ptr, mid), from_raw_parts(ptr.add(mid), len - mid)) }
|
||||
}
|
||||
|
||||
/// Divides one mutable slice into two at an index, without doing bounds checking.
|
||||
@ -2018,17 +2012,16 @@ impl<T> [T] {
|
||||
let len = self.len();
|
||||
let ptr = self.as_mut_ptr();
|
||||
|
||||
debug_assert_nounwind!(
|
||||
mid <= len,
|
||||
"slice::split_at_mut_unchecked requires the index to be within the slice",
|
||||
);
|
||||
|
||||
// SAFETY: Caller has to check that `0 <= mid <= self.len()`.
|
||||
//
|
||||
// `[ptr; mid]` and `[mid; len]` are not overlapping, so returning a mutable reference
|
||||
// is fine.
|
||||
unsafe {
|
||||
assert_unsafe_precondition!(
|
||||
"slice::split_at_mut_unchecked requires the index to be within the slice",
|
||||
(mid: usize, len: usize) => mid <= len
|
||||
);
|
||||
(from_raw_parts_mut(ptr, mid), from_raw_parts_mut(ptr.add(mid), len - mid))
|
||||
}
|
||||
unsafe { (from_raw_parts_mut(ptr, mid), from_raw_parts_mut(ptr.add(mid), len - mid)) }
|
||||
}
|
||||
|
||||
/// Divides one slice into an array and a remainder slice at an index.
|
||||
|
@ -1,8 +1,8 @@
|
||||
//! Trait implementations for `str`.
|
||||
|
||||
use crate::cmp::Ordering;
|
||||
use crate::intrinsics::assert_unsafe_precondition;
|
||||
use crate::ops;
|
||||
use crate::panic::debug_assert_nounwind;
|
||||
use crate::ptr;
|
||||
use crate::slice::SliceIndex;
|
||||
|
||||
@ -191,39 +191,35 @@ unsafe impl SliceIndex<str> for ops::Range<usize> {
|
||||
#[inline]
|
||||
unsafe fn get_unchecked(self, slice: *const str) -> *const Self::Output {
|
||||
let slice = slice as *const [u8];
|
||||
|
||||
debug_assert_nounwind!(
|
||||
// We'd like to check that the bounds are on char boundaries,
|
||||
// but there's not really a way to do so without reading
|
||||
// behind the pointer, which has aliasing implications.
|
||||
// It's also not possible to move this check up to
|
||||
// `str::get_unchecked` without adding a special function
|
||||
// to `SliceIndex` just for this.
|
||||
self.end >= self.start && self.end <= slice.len(),
|
||||
"str::get_unchecked requires that the range is within the string slice",
|
||||
);
|
||||
|
||||
// SAFETY: the caller guarantees that `self` is in bounds of `slice`
|
||||
// which satisfies all the conditions for `add`.
|
||||
let ptr = unsafe {
|
||||
let this = ops::Range { ..self };
|
||||
assert_unsafe_precondition!(
|
||||
"str::get_unchecked requires that the range is within the string slice",
|
||||
(this: ops::Range<usize>, slice: *const [u8]) =>
|
||||
// We'd like to check that the bounds are on char boundaries,
|
||||
// but there's not really a way to do so without reading
|
||||
// behind the pointer, which has aliasing implications.
|
||||
// It's also not possible to move this check up to
|
||||
// `str::get_unchecked` without adding a special function
|
||||
// to `SliceIndex` just for this.
|
||||
this.end >= this.start && this.end <= slice.len()
|
||||
);
|
||||
slice.as_ptr().add(self.start)
|
||||
};
|
||||
let ptr = unsafe { slice.as_ptr().add(self.start) };
|
||||
let len = self.end - self.start;
|
||||
ptr::slice_from_raw_parts(ptr, len) as *const str
|
||||
}
|
||||
#[inline]
|
||||
unsafe fn get_unchecked_mut(self, slice: *mut str) -> *mut Self::Output {
|
||||
let slice = slice as *mut [u8];
|
||||
|
||||
debug_assert_nounwind!(
|
||||
self.end >= self.start && self.end <= slice.len(),
|
||||
"str::get_unchecked_mut requires that the range is within the string slice",
|
||||
);
|
||||
|
||||
// SAFETY: see comments for `get_unchecked`.
|
||||
let ptr = unsafe {
|
||||
let this = ops::Range { ..self };
|
||||
assert_unsafe_precondition!(
|
||||
"str::get_unchecked_mut requires that the range is within the string slice",
|
||||
(this: ops::Range<usize>, slice: *mut [u8]) =>
|
||||
this.end >= this.start && this.end <= slice.len()
|
||||
);
|
||||
slice.as_mut_ptr().add(self.start)
|
||||
};
|
||||
let ptr = unsafe { slice.as_mut_ptr().add(self.start) };
|
||||
let len = self.end - self.start;
|
||||
ptr::slice_from_raw_parts_mut(ptr, len) as *mut str
|
||||
}
|
||||
|
@ -20,33 +20,30 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> {
|
||||
debug self => _2;
|
||||
debug slice => _5;
|
||||
let mut _6: *mut u32;
|
||||
let mut _9: &[&str];
|
||||
scope 5 {
|
||||
debug this => _2;
|
||||
scope 6 {
|
||||
scope 7 (inlined <usize as SliceIndex<[T]>>::get_unchecked_mut::runtime::<u32>) {
|
||||
debug this => _2;
|
||||
debug slice => _5;
|
||||
scope 8 (inlined ptr::mut_ptr::<impl *mut [u32]>::len) {
|
||||
debug self => _5;
|
||||
let mut _9: *const [u32];
|
||||
scope 9 (inlined std::ptr::metadata::<[u32]>) {
|
||||
debug ptr => _9;
|
||||
scope 10 {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
scope 11 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) {
|
||||
debug self => _5;
|
||||
}
|
||||
scope 12 (inlined ptr::mut_ptr::<impl *mut u32>::add) {
|
||||
debug self => _6;
|
||||
debug count => _2;
|
||||
scope 13 {
|
||||
}
|
||||
scope 10 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) {
|
||||
debug self => _5;
|
||||
}
|
||||
scope 11 (inlined ptr::mut_ptr::<impl *mut u32>::add) {
|
||||
debug self => _6;
|
||||
debug count => _2;
|
||||
scope 12 {
|
||||
}
|
||||
}
|
||||
}
|
||||
scope 6 (inlined ptr::mut_ptr::<impl *mut [u32]>::len) {
|
||||
debug self => _5;
|
||||
let mut _10: *const [u32];
|
||||
scope 7 (inlined std::ptr::metadata::<[u32]>) {
|
||||
debug ptr => _10;
|
||||
scope 8 {
|
||||
}
|
||||
}
|
||||
}
|
||||
scope 9 (inlined Arguments::<'_>::new_const) {
|
||||
debug pieces => _9;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -73,10 +70,12 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> {
|
||||
StorageLive(_5);
|
||||
_5 = &raw mut (*_1);
|
||||
StorageLive(_9);
|
||||
StorageLive(_10);
|
||||
StorageLive(_6);
|
||||
_6 = _5 as *mut u32 (PtrToPtr);
|
||||
_7 = Offset(_6, _2);
|
||||
StorageDead(_6);
|
||||
StorageDead(_10);
|
||||
StorageDead(_9);
|
||||
StorageDead(_5);
|
||||
_8 = &mut (*_7);
|
||||
|
@ -20,33 +20,30 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> {
|
||||
debug self => _2;
|
||||
debug slice => _5;
|
||||
let mut _6: *mut u32;
|
||||
let mut _9: &[&str];
|
||||
scope 5 {
|
||||
debug this => _2;
|
||||
scope 6 {
|
||||
scope 7 (inlined <usize as SliceIndex<[T]>>::get_unchecked_mut::runtime::<u32>) {
|
||||
debug this => _2;
|
||||
debug slice => _5;
|
||||
scope 8 (inlined ptr::mut_ptr::<impl *mut [u32]>::len) {
|
||||
debug self => _5;
|
||||
let mut _9: *const [u32];
|
||||
scope 9 (inlined std::ptr::metadata::<[u32]>) {
|
||||
debug ptr => _9;
|
||||
scope 10 {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
scope 11 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) {
|
||||
debug self => _5;
|
||||
}
|
||||
scope 12 (inlined ptr::mut_ptr::<impl *mut u32>::add) {
|
||||
debug self => _6;
|
||||
debug count => _2;
|
||||
scope 13 {
|
||||
}
|
||||
scope 10 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) {
|
||||
debug self => _5;
|
||||
}
|
||||
scope 11 (inlined ptr::mut_ptr::<impl *mut u32>::add) {
|
||||
debug self => _6;
|
||||
debug count => _2;
|
||||
scope 12 {
|
||||
}
|
||||
}
|
||||
}
|
||||
scope 6 (inlined ptr::mut_ptr::<impl *mut [u32]>::len) {
|
||||
debug self => _5;
|
||||
let mut _10: *const [u32];
|
||||
scope 7 (inlined std::ptr::metadata::<[u32]>) {
|
||||
debug ptr => _10;
|
||||
scope 8 {
|
||||
}
|
||||
}
|
||||
}
|
||||
scope 9 (inlined Arguments::<'_>::new_const) {
|
||||
debug pieces => _9;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -73,10 +70,12 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> {
|
||||
StorageLive(_5);
|
||||
_5 = &raw mut (*_1);
|
||||
StorageLive(_9);
|
||||
StorageLive(_10);
|
||||
StorageLive(_6);
|
||||
_6 = _5 as *mut u32 (PtrToPtr);
|
||||
_7 = Offset(_6, _2);
|
||||
StorageDead(_6);
|
||||
StorageDead(_10);
|
||||
StorageDead(_9);
|
||||
StorageDead(_5);
|
||||
_8 = &mut (*_7);
|
||||
|
@ -19,56 +19,51 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) ->
|
||||
debug slice => _5;
|
||||
let mut _7: *mut u32;
|
||||
let mut _8: *mut u32;
|
||||
let mut _14: &[&str];
|
||||
scope 4 {
|
||||
debug ((this: std::ops::Range<usize>).0: usize) => _3;
|
||||
debug ((this: std::ops::Range<usize>).1: usize) => _4;
|
||||
let _6: usize;
|
||||
scope 5 {
|
||||
let _6: usize;
|
||||
scope 6 {
|
||||
debug new_len => _6;
|
||||
scope 11 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) {
|
||||
debug self => _5;
|
||||
}
|
||||
scope 12 (inlined ptr::mut_ptr::<impl *mut u32>::add) {
|
||||
debug self => _7;
|
||||
debug count => _3;
|
||||
scope 13 {
|
||||
}
|
||||
}
|
||||
scope 14 (inlined slice_from_raw_parts_mut::<u32>) {
|
||||
debug data => _8;
|
||||
debug len => _6;
|
||||
let mut _9: *mut ();
|
||||
scope 15 (inlined ptr::mut_ptr::<impl *mut u32>::cast::<()>) {
|
||||
debug self => _8;
|
||||
}
|
||||
scope 16 (inlined std::ptr::from_raw_parts_mut::<[u32]>) {
|
||||
debug data_address => _9;
|
||||
debug metadata => _6;
|
||||
let mut _10: *const ();
|
||||
let mut _11: std::ptr::metadata::PtrComponents<[u32]>;
|
||||
let mut _12: std::ptr::metadata::PtrRepr<[u32]>;
|
||||
scope 17 {
|
||||
}
|
||||
}
|
||||
debug new_len => _6;
|
||||
scope 10 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) {
|
||||
debug self => _5;
|
||||
}
|
||||
scope 11 (inlined ptr::mut_ptr::<impl *mut u32>::add) {
|
||||
debug self => _7;
|
||||
debug count => _3;
|
||||
scope 12 {
|
||||
}
|
||||
}
|
||||
scope 7 (inlined <std::ops::Range<usize> as SliceIndex<[T]>>::get_unchecked_mut::runtime::<u32>) {
|
||||
debug ((this: std::ops::Range<usize>).0: usize) => _3;
|
||||
debug ((this: std::ops::Range<usize>).1: usize) => _4;
|
||||
debug slice => _5;
|
||||
scope 8 (inlined ptr::mut_ptr::<impl *mut [u32]>::len) {
|
||||
debug self => _5;
|
||||
let mut _14: *const [u32];
|
||||
scope 9 (inlined std::ptr::metadata::<[u32]>) {
|
||||
debug ptr => _14;
|
||||
scope 10 {
|
||||
}
|
||||
scope 13 (inlined slice_from_raw_parts_mut::<u32>) {
|
||||
debug data => _8;
|
||||
debug len => _6;
|
||||
let mut _9: *mut ();
|
||||
scope 14 (inlined ptr::mut_ptr::<impl *mut u32>::cast::<()>) {
|
||||
debug self => _8;
|
||||
}
|
||||
scope 15 (inlined std::ptr::from_raw_parts_mut::<[u32]>) {
|
||||
debug data_address => _9;
|
||||
debug metadata => _6;
|
||||
let mut _10: *const ();
|
||||
let mut _11: std::ptr::metadata::PtrComponents<[u32]>;
|
||||
let mut _12: std::ptr::metadata::PtrRepr<[u32]>;
|
||||
scope 16 {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
scope 6 (inlined ptr::mut_ptr::<impl *mut [u32]>::len) {
|
||||
debug self => _5;
|
||||
let mut _15: *const [u32];
|
||||
scope 7 (inlined std::ptr::metadata::<[u32]>) {
|
||||
debug ptr => _15;
|
||||
scope 8 {
|
||||
}
|
||||
}
|
||||
}
|
||||
scope 9 (inlined Arguments::<'_>::new_const) {
|
||||
debug pieces => _14;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -78,8 +73,9 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) ->
|
||||
_4 = move (_2.1: usize);
|
||||
StorageLive(_5);
|
||||
_5 = &raw mut (*_1);
|
||||
StorageLive(_6);
|
||||
StorageLive(_14);
|
||||
StorageLive(_6);
|
||||
StorageLive(_15);
|
||||
_6 = SubUnchecked(_4, _3);
|
||||
StorageLive(_8);
|
||||
StorageLive(_7);
|
||||
@ -100,8 +96,9 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) ->
|
||||
StorageDead(_12);
|
||||
StorageDead(_9);
|
||||
StorageDead(_8);
|
||||
StorageDead(_14);
|
||||
StorageDead(_15);
|
||||
StorageDead(_6);
|
||||
StorageDead(_14);
|
||||
StorageDead(_5);
|
||||
_0 = &mut (*_13);
|
||||
return;
|
||||
|
@ -19,56 +19,51 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) ->
|
||||
debug slice => _5;
|
||||
let mut _7: *mut u32;
|
||||
let mut _8: *mut u32;
|
||||
let mut _14: &[&str];
|
||||
scope 4 {
|
||||
debug ((this: std::ops::Range<usize>).0: usize) => _3;
|
||||
debug ((this: std::ops::Range<usize>).1: usize) => _4;
|
||||
let _6: usize;
|
||||
scope 5 {
|
||||
let _6: usize;
|
||||
scope 6 {
|
||||
debug new_len => _6;
|
||||
scope 11 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) {
|
||||
debug self => _5;
|
||||
}
|
||||
scope 12 (inlined ptr::mut_ptr::<impl *mut u32>::add) {
|
||||
debug self => _7;
|
||||
debug count => _3;
|
||||
scope 13 {
|
||||
}
|
||||
}
|
||||
scope 14 (inlined slice_from_raw_parts_mut::<u32>) {
|
||||
debug data => _8;
|
||||
debug len => _6;
|
||||
let mut _9: *mut ();
|
||||
scope 15 (inlined ptr::mut_ptr::<impl *mut u32>::cast::<()>) {
|
||||
debug self => _8;
|
||||
}
|
||||
scope 16 (inlined std::ptr::from_raw_parts_mut::<[u32]>) {
|
||||
debug data_address => _9;
|
||||
debug metadata => _6;
|
||||
let mut _10: *const ();
|
||||
let mut _11: std::ptr::metadata::PtrComponents<[u32]>;
|
||||
let mut _12: std::ptr::metadata::PtrRepr<[u32]>;
|
||||
scope 17 {
|
||||
}
|
||||
}
|
||||
debug new_len => _6;
|
||||
scope 10 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) {
|
||||
debug self => _5;
|
||||
}
|
||||
scope 11 (inlined ptr::mut_ptr::<impl *mut u32>::add) {
|
||||
debug self => _7;
|
||||
debug count => _3;
|
||||
scope 12 {
|
||||
}
|
||||
}
|
||||
scope 7 (inlined <std::ops::Range<usize> as SliceIndex<[T]>>::get_unchecked_mut::runtime::<u32>) {
|
||||
debug ((this: std::ops::Range<usize>).0: usize) => _3;
|
||||
debug ((this: std::ops::Range<usize>).1: usize) => _4;
|
||||
debug slice => _5;
|
||||
scope 8 (inlined ptr::mut_ptr::<impl *mut [u32]>::len) {
|
||||
debug self => _5;
|
||||
let mut _14: *const [u32];
|
||||
scope 9 (inlined std::ptr::metadata::<[u32]>) {
|
||||
debug ptr => _14;
|
||||
scope 10 {
|
||||
}
|
||||
scope 13 (inlined slice_from_raw_parts_mut::<u32>) {
|
||||
debug data => _8;
|
||||
debug len => _6;
|
||||
let mut _9: *mut ();
|
||||
scope 14 (inlined ptr::mut_ptr::<impl *mut u32>::cast::<()>) {
|
||||
debug self => _8;
|
||||
}
|
||||
scope 15 (inlined std::ptr::from_raw_parts_mut::<[u32]>) {
|
||||
debug data_address => _9;
|
||||
debug metadata => _6;
|
||||
let mut _10: *const ();
|
||||
let mut _11: std::ptr::metadata::PtrComponents<[u32]>;
|
||||
let mut _12: std::ptr::metadata::PtrRepr<[u32]>;
|
||||
scope 16 {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
scope 6 (inlined ptr::mut_ptr::<impl *mut [u32]>::len) {
|
||||
debug self => _5;
|
||||
let mut _15: *const [u32];
|
||||
scope 7 (inlined std::ptr::metadata::<[u32]>) {
|
||||
debug ptr => _15;
|
||||
scope 8 {
|
||||
}
|
||||
}
|
||||
}
|
||||
scope 9 (inlined Arguments::<'_>::new_const) {
|
||||
debug pieces => _14;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -78,8 +73,9 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) ->
|
||||
_4 = move (_2.1: usize);
|
||||
StorageLive(_5);
|
||||
_5 = &raw mut (*_1);
|
||||
StorageLive(_6);
|
||||
StorageLive(_14);
|
||||
StorageLive(_6);
|
||||
StorageLive(_15);
|
||||
_6 = SubUnchecked(_4, _3);
|
||||
StorageLive(_8);
|
||||
StorageLive(_7);
|
||||
@ -100,8 +96,9 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) ->
|
||||
StorageDead(_12);
|
||||
StorageDead(_9);
|
||||
StorageDead(_8);
|
||||
StorageDead(_14);
|
||||
StorageDead(_15);
|
||||
StorageDead(_6);
|
||||
StorageDead(_14);
|
||||
StorageDead(_5);
|
||||
_0 = &mut (*_13);
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:20:1
|
||||
--> $DIR/raw-bytes.rs:21:1
|
||||
|
|
||||
LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x00000001, but expected a valid enum tag
|
||||
@ -10,7 +10,7 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:28:1
|
||||
--> $DIR/raw-bytes.rs:29:1
|
||||
|
|
||||
LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x00000000, but expected a valid enum tag
|
||||
@ -21,7 +21,7 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:42:1
|
||||
--> $DIR/raw-bytes.rs:43:1
|
||||
|
|
||||
LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
|
||||
@ -32,7 +32,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:44:1
|
||||
--> $DIR/raw-bytes.rs:45:1
|
||||
|
|
||||
LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
|
||||
@ -43,7 +43,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:50:1
|
||||
--> $DIR/raw-bytes.rs:51:1
|
||||
|
|
||||
LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) }));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)
|
||||
@ -54,7 +54,7 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:54:1
|
||||
--> $DIR/raw-bytes.rs:55:1
|
||||
|
|
||||
LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1
|
||||
@ -65,7 +65,7 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:57:1
|
||||
--> $DIR/raw-bytes.rs:58:1
|
||||
|
|
||||
LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1
|
||||
@ -76,7 +76,7 @@ LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:59:1
|
||||
--> $DIR/raw-bytes.rs:60:1
|
||||
|
|
||||
LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1
|
||||
@ -87,7 +87,7 @@ LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:65:1
|
||||
--> $DIR/raw-bytes.rs:66:1
|
||||
|
|
||||
LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30
|
||||
@ -98,7 +98,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:71:1
|
||||
--> $DIR/raw-bytes.rs:72:1
|
||||
|
|
||||
LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30
|
||||
@ -109,7 +109,7 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:74:1
|
||||
--> $DIR/raw-bytes.rs:75:1
|
||||
|
|
||||
LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1
|
||||
@ -120,7 +120,7 @@ LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:82:1
|
||||
--> $DIR/raw-bytes.rs:83:1
|
||||
|
|
||||
LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
|
||||
@ -131,7 +131,7 @@ LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:86:1
|
||||
--> $DIR/raw-bytes.rs:87:1
|
||||
|
|
||||
LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1)
|
||||
@ -142,7 +142,7 @@ LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:90:1
|
||||
--> $DIR/raw-bytes.rs:91:1
|
||||
|
|
||||
LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
|
||||
| ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
|
||||
@ -153,7 +153,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:93:1
|
||||
--> $DIR/raw-bytes.rs:94:1
|
||||
|
|
||||
LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box
|
||||
@ -164,7 +164,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:96:1
|
||||
--> $DIR/raw-bytes.rs:97:1
|
||||
|
|
||||
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance)
|
||||
@ -175,7 +175,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:99:1
|
||||
--> $DIR/raw-bytes.rs:100:1
|
||||
|
|
||||
LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance)
|
||||
@ -186,7 +186,7 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:102:1
|
||||
--> $DIR/raw-bytes.rs:103:1
|
||||
|
|
||||
LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer
|
||||
@ -197,7 +197,7 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:104:1
|
||||
--> $DIR/raw-bytes.rs:105:1
|
||||
|
|
||||
LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer
|
||||
@ -208,7 +208,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:106:1
|
||||
--> $DIR/raw-bytes.rs:107:1
|
||||
|
|
||||
LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3, but expected a function pointer
|
||||
@ -219,7 +219,7 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:112:1
|
||||
--> $DIR/raw-bytes.rs:113:1
|
||||
|
|
||||
LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar
|
||||
@ -230,7 +230,7 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:137:1
|
||||
--> $DIR/raw-bytes.rs:138:1
|
||||
|
|
||||
LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
|
||||
@ -241,7 +241,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:139:1
|
||||
--> $DIR/raw-bytes.rs:140:1
|
||||
|
|
||||
LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object
|
||||
@ -252,7 +252,7 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:141:1
|
||||
--> $DIR/raw-bytes.rs:142:1
|
||||
|
|
||||
LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
|
||||
@ -263,7 +263,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize:
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:144:1
|
||||
--> $DIR/raw-bytes.rs:145:1
|
||||
|
|
||||
LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string
|
||||
@ -274,7 +274,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:146:1
|
||||
--> $DIR/raw-bytes.rs:147:1
|
||||
|
|
||||
LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string
|
||||
@ -285,7 +285,7 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:148:1
|
||||
--> $DIR/raw-bytes.rs:149:1
|
||||
|
|
||||
LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered a pointer, but expected a string
|
||||
@ -298,7 +298,7 @@ LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>
|
||||
= 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/raw-bytes.rs:152:1
|
||||
--> $DIR/raw-bytes.rs:153:1
|
||||
|
|
||||
LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
|
||||
@ -309,7 +309,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:154:1
|
||||
--> $DIR/raw-bytes.rs:155:1
|
||||
|
|
||||
LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
|
||||
@ -320,7 +320,7 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:157:1
|
||||
--> $DIR/raw-bytes.rs:158:1
|
||||
|
|
||||
LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation)
|
||||
@ -331,7 +331,7 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:160:1
|
||||
--> $DIR/raw-bytes.rs:161:1
|
||||
|
|
||||
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean
|
||||
@ -342,13 +342,13 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
||||
}
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/raw-bytes.rs:160:40
|
||||
--> $DIR/raw-bytes.rs:161:40
|
||||
|
|
||||
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:166:1
|
||||
--> $DIR/raw-bytes.rs:167:1
|
||||
|
|
||||
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean
|
||||
@ -359,13 +359,13 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3
|
||||
}
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/raw-bytes.rs:166:42
|
||||
--> $DIR/raw-bytes.rs:167:42
|
||||
|
|
||||
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:170:1
|
||||
--> $DIR/raw-bytes.rs:171:1
|
||||
|
|
||||
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean
|
||||
@ -376,13 +376,13 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran
|
||||
}
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/raw-bytes.rs:170:42
|
||||
--> $DIR/raw-bytes.rs:171:42
|
||||
|
|
||||
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:175:1
|
||||
--> $DIR/raw-bytes.rs:176:1
|
||||
|
|
||||
LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC17, but expected a vtable pointer
|
||||
@ -393,7 +393,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:179:1
|
||||
--> $DIR/raw-bytes.rs:180:1
|
||||
|
|
||||
LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC19, but expected a vtable pointer
|
||||
@ -404,7 +404,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:183:1
|
||||
--> $DIR/raw-bytes.rs:184:1
|
||||
|
|
||||
LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer
|
||||
@ -415,7 +415,7 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:186:1
|
||||
--> $DIR/raw-bytes.rs:187:1
|
||||
|
|
||||
LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC22, but expected a vtable pointer
|
||||
@ -426,7 +426,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:190:1
|
||||
--> $DIR/raw-bytes.rs:191:1
|
||||
|
|
||||
LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean
|
||||
@ -437,7 +437,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_,
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:194:1
|
||||
--> $DIR/raw-bytes.rs:195:1
|
||||
|
|
||||
LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer
|
||||
@ -448,7 +448,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:196:1
|
||||
--> $DIR/raw-bytes.rs:197:1
|
||||
|
|
||||
LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC27, but expected a vtable pointer
|
||||
@ -459,7 +459,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transm
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:201:1
|
||||
--> $DIR/raw-bytes.rs:202:1
|
||||
|
|
||||
LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchecked(0x1000, 0x00) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x00000000, but expected a valid enum tag
|
||||
@ -470,7 +470,7 @@ LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchec
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:205:1
|
||||
--> $DIR/raw-bytes.rs:206:1
|
||||
|
|
||||
LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unchecked(9, 3) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x00000003, but expected a valid enum tag
|
||||
@ -481,7 +481,7 @@ LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unche
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:209:1
|
||||
--> $DIR/raw-bytes.rs:210:1
|
||||
|
|
||||
LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) };
|
||||
| ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type [!; 1]
|
||||
@ -492,7 +492,7 @@ LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:210:1
|
||||
--> $DIR/raw-bytes.rs:211:1
|
||||
|
|
||||
LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) };
|
||||
| ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!`
|
||||
@ -503,7 +503,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:211:1
|
||||
--> $DIR/raw-bytes.rs:212:1
|
||||
|
|
||||
LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) };
|
||||
| ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!`
|
||||
@ -514,7 +514,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:215:1
|
||||
--> $DIR/raw-bytes.rs:216: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
|
||||
@ -525,7 +525,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/raw-bytes.rs:218:1
|
||||
--> $DIR/raw-bytes.rs:219:1
|
||||
|
|
||||
LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer
|
||||
@ -538,7 +538,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem:
|
||||
= 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/raw-bytes.rs:221:1
|
||||
--> $DIR/raw-bytes.rs:222: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
|
||||
@ -549,7 +549,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/raw-bytes.rs:225:1
|
||||
--> $DIR/raw-bytes.rs:226:1
|
||||
|
|
||||
LL | pub static S7: &[u16] = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer
|
||||
@ -560,7 +560,7 @@ LL | pub static S7: &[u16] = unsafe {
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:232:1
|
||||
--> $DIR/raw-bytes.rs:233:1
|
||||
|
|
||||
LL | pub static R4: &[u8] = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer
|
||||
@ -571,7 +571,7 @@ LL | pub static R4: &[u8] = unsafe {
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:237:1
|
||||
--> $DIR/raw-bytes.rs:238:1
|
||||
|
|
||||
LL | pub static R5: &[u8] = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer
|
||||
@ -584,7 +584,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/raw-bytes.rs:242:1
|
||||
--> $DIR/raw-bytes.rs:243:1
|
||||
|
|
||||
LL | pub static R6: &[bool] = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:20:1
|
||||
--> $DIR/raw-bytes.rs:21:1
|
||||
|
|
||||
LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0000000000000001, but expected a valid enum tag
|
||||
@ -10,7 +10,7 @@ LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:28:1
|
||||
--> $DIR/raw-bytes.rs:29:1
|
||||
|
|
||||
LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered 0x0000000000000000, but expected a valid enum tag
|
||||
@ -21,7 +21,7 @@ LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:42:1
|
||||
--> $DIR/raw-bytes.rs:43:1
|
||||
|
|
||||
LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
|
||||
@ -32,7 +32,7 @@ LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:44:1
|
||||
--> $DIR/raw-bytes.rs:45:1
|
||||
|
|
||||
LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
|
||||
@ -43,7 +43,7 @@ LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:50:1
|
||||
--> $DIR/raw-bytes.rs:51:1
|
||||
|
|
||||
LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) }));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0.1: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)
|
||||
@ -54,7 +54,7 @@ LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::tran
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:54:1
|
||||
--> $DIR/raw-bytes.rs:55:1
|
||||
|
|
||||
LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1
|
||||
@ -65,7 +65,7 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:57:1
|
||||
--> $DIR/raw-bytes.rs:58:1
|
||||
|
|
||||
LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1
|
||||
@ -76,7 +76,7 @@ LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:59:1
|
||||
--> $DIR/raw-bytes.rs:60:1
|
||||
|
|
||||
LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1
|
||||
@ -87,7 +87,7 @@ LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:65:1
|
||||
--> $DIR/raw-bytes.rs:66:1
|
||||
|
|
||||
LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 42, but expected something in the range 10..=30
|
||||
@ -98,7 +98,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:71:1
|
||||
--> $DIR/raw-bytes.rs:72:1
|
||||
|
|
||||
LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 20, but expected something less or equal to 10, or greater or equal to 30
|
||||
@ -109,7 +109,7 @@ LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:74:1
|
||||
--> $DIR/raw-bytes.rs:75:1
|
||||
|
|
||||
LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1
|
||||
@ -120,7 +120,7 @@ LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe {
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:82:1
|
||||
--> $DIR/raw-bytes.rs:83:1
|
||||
|
|
||||
LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned reference (required 2 byte alignment but found 1)
|
||||
@ -131,7 +131,7 @@ LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:86:1
|
||||
--> $DIR/raw-bytes.rs:87:1
|
||||
|
|
||||
LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered an unaligned box (required 2 byte alignment but found 1)
|
||||
@ -142,7 +142,7 @@ LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:90:1
|
||||
--> $DIR/raw-bytes.rs:91:1
|
||||
|
|
||||
LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
|
||||
| ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null reference
|
||||
@ -153,7 +153,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:93:1
|
||||
--> $DIR/raw-bytes.rs:94:1
|
||||
|
|
||||
LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a null box
|
||||
@ -164,7 +164,7 @@ LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:96:1
|
||||
--> $DIR/raw-bytes.rs:97:1
|
||||
|
|
||||
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (0x539[noalloc] has no provenance)
|
||||
@ -175,7 +175,7 @@ LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:99:1
|
||||
--> $DIR/raw-bytes.rs:100:1
|
||||
|
|
||||
LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (0x539[noalloc] has no provenance)
|
||||
@ -186,7 +186,7 @@ LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:102:1
|
||||
--> $DIR/raw-bytes.rs:103:1
|
||||
|
|
||||
LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a function pointer
|
||||
@ -197,7 +197,7 @@ LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:104:1
|
||||
--> $DIR/raw-bytes.rs:105:1
|
||||
|
|
||||
LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xd[noalloc], but expected a function pointer
|
||||
@ -208,7 +208,7 @@ LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:106:1
|
||||
--> $DIR/raw-bytes.rs:107:1
|
||||
|
|
||||
LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC3, but expected a function pointer
|
||||
@ -219,7 +219,7 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:112:1
|
||||
--> $DIR/raw-bytes.rs:113:1
|
||||
|
|
||||
LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar
|
||||
@ -230,7 +230,7 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:137:1
|
||||
--> $DIR/raw-bytes.rs:138:1
|
||||
|
|
||||
LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
|
||||
@ -241,7 +241,7 @@ LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:139:1
|
||||
--> $DIR/raw-bytes.rs:140:1
|
||||
|
|
||||
LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered invalid reference metadata: slice is bigger than largest supported object
|
||||
@ -252,7 +252,7 @@ LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, us
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:141:1
|
||||
--> $DIR/raw-bytes.rs:142:1
|
||||
|
|
||||
LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
|
||||
@ -263,7 +263,7 @@ LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize:
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:144:1
|
||||
--> $DIR/raw-bytes.rs:145:1
|
||||
|
|
||||
LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered uninitialized memory, but expected a string
|
||||
@ -274,7 +274,7 @@ LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit:
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:146:1
|
||||
--> $DIR/raw-bytes.rs:147:1
|
||||
|
|
||||
LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered uninitialized memory, but expected a string
|
||||
@ -285,7 +285,7 @@ LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUni
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:148:1
|
||||
--> $DIR/raw-bytes.rs:149:1
|
||||
|
|
||||
LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered a pointer, but expected a string
|
||||
@ -298,7 +298,7 @@ LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>
|
||||
= 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/raw-bytes.rs:152:1
|
||||
--> $DIR/raw-bytes.rs:153:1
|
||||
|
|
||||
LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
|
||||
@ -309,7 +309,7 @@ LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:154:1
|
||||
--> $DIR/raw-bytes.rs:155:1
|
||||
|
|
||||
LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
|
||||
@ -320,7 +320,7 @@ LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, is
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:157:1
|
||||
--> $DIR/raw-bytes.rs:158:1
|
||||
|
|
||||
LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling box (going beyond the bounds of its allocation)
|
||||
@ -331,7 +331,7 @@ LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999us
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:160:1
|
||||
--> $DIR/raw-bytes.rs:161:1
|
||||
|
|
||||
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x03, but expected a boolean
|
||||
@ -342,13 +342,13 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
||||
}
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/raw-bytes.rs:160:40
|
||||
--> $DIR/raw-bytes.rs:161:40
|
||||
|
|
||||
LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:166:1
|
||||
--> $DIR/raw-bytes.rs:167:1
|
||||
|
|
||||
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.0: encountered 0x03, but expected a boolean
|
||||
@ -359,13 +359,13 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3
|
||||
}
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/raw-bytes.rs:166:42
|
||||
--> $DIR/raw-bytes.rs:167:42
|
||||
|
|
||||
LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:170:1
|
||||
--> $DIR/raw-bytes.rs:171:1
|
||||
|
|
||||
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.1[0]: encountered 0x03, but expected a boolean
|
||||
@ -376,13 +376,13 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran
|
||||
}
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> $DIR/raw-bytes.rs:170:42
|
||||
--> $DIR/raw-bytes.rs:171:42
|
||||
|
|
||||
LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:175:1
|
||||
--> $DIR/raw-bytes.rs:176:1
|
||||
|
|
||||
LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC17, but expected a vtable pointer
|
||||
@ -393,7 +393,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:179:1
|
||||
--> $DIR/raw-bytes.rs:180:1
|
||||
|
|
||||
LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC19, but expected a vtable pointer
|
||||
@ -404,7 +404,7 @@ LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:183:1
|
||||
--> $DIR/raw-bytes.rs:184:1
|
||||
|
|
||||
LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0x4[noalloc], but expected a vtable pointer
|
||||
@ -415,7 +415,7 @@ LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:186:1
|
||||
--> $DIR/raw-bytes.rs:187:1
|
||||
|
|
||||
LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered ALLOC22, but expected a vtable pointer
|
||||
@ -426,7 +426,7 @@ LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::trans
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:190:1
|
||||
--> $DIR/raw-bytes.rs:191:1
|
||||
|
|
||||
LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>: encountered 0x03, but expected a boolean
|
||||
@ -437,7 +437,7 @@ LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_,
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:194:1
|
||||
--> $DIR/raw-bytes.rs:195:1
|
||||
|
|
||||
LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered null pointer, but expected a vtable pointer
|
||||
@ -448,7 +448,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:196:1
|
||||
--> $DIR/raw-bytes.rs:197:1
|
||||
|
|
||||
LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered ALLOC27, but expected a vtable pointer
|
||||
@ -459,7 +459,7 @@ LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transm
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:201:1
|
||||
--> $DIR/raw-bytes.rs:202:1
|
||||
|
|
||||
LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchecked(0x1000, 0x00) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x0000000000000000, but expected a valid enum tag
|
||||
@ -470,7 +470,7 @@ LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchec
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:205:1
|
||||
--> $DIR/raw-bytes.rs:206:1
|
||||
|
|
||||
LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unchecked(9, 3) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x0000000000000003, but expected a valid enum tag
|
||||
@ -481,7 +481,7 @@ LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unche
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:209:1
|
||||
--> $DIR/raw-bytes.rs:210:1
|
||||
|
|
||||
LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) };
|
||||
| ^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type [!; 1]
|
||||
@ -492,7 +492,7 @@ LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:210:1
|
||||
--> $DIR/raw-bytes.rs:211:1
|
||||
|
|
||||
LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) };
|
||||
| ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!`
|
||||
@ -503,7 +503,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:211:1
|
||||
--> $DIR/raw-bytes.rs:212:1
|
||||
|
|
||||
LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) };
|
||||
| ^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a value of the never type `!`
|
||||
@ -514,7 +514,7 @@ LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) };
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:215:1
|
||||
--> $DIR/raw-bytes.rs:216: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
|
||||
@ -525,7 +525,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/raw-bytes.rs:218:1
|
||||
--> $DIR/raw-bytes.rs:219:1
|
||||
|
|
||||
LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer
|
||||
@ -538,7 +538,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem:
|
||||
= 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/raw-bytes.rs:221:1
|
||||
--> $DIR/raw-bytes.rs:222: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
|
||||
@ -549,7 +549,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/raw-bytes.rs:225:1
|
||||
--> $DIR/raw-bytes.rs:226:1
|
||||
|
|
||||
LL | pub static S7: &[u16] = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[1]: encountered uninitialized memory, but expected an integer
|
||||
@ -560,7 +560,7 @@ LL | pub static S7: &[u16] = unsafe {
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:232:1
|
||||
--> $DIR/raw-bytes.rs:233:1
|
||||
|
|
||||
LL | pub static R4: &[u8] = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer
|
||||
@ -571,7 +571,7 @@ LL | pub static R4: &[u8] = unsafe {
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/raw-bytes.rs:237:1
|
||||
--> $DIR/raw-bytes.rs:238:1
|
||||
|
|
||||
LL | pub static R5: &[u8] = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered a pointer, but expected an integer
|
||||
@ -584,7 +584,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/raw-bytes.rs:242:1
|
||||
--> $DIR/raw-bytes.rs:243:1
|
||||
|
|
||||
LL | pub static R6: &[bool] = unsafe {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>[0]: encountered 0x11, but expected a boolean
|
||||
|
@ -1,6 +1,7 @@
|
||||
// stderr-per-bitwidth
|
||||
// ignore-endian-big
|
||||
// ignore-tidy-linelength
|
||||
// ignore-debug debug assertions catch some UB too early
|
||||
// normalize-stderr-test "╾─*ALLOC[0-9]+(\+[a-z0-9]+)?─*╼" -> "╾ALLOC_ID$1╼"
|
||||
|
||||
#![feature(never_type, rustc_attrs, ptr_metadata, slice_from_ptr_range, const_slice_from_ptr_range)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/alloc.rs:11:1
|
||||
--> $DIR/alloc.rs:12:1
|
||||
|
|
||||
LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchecked(0x1000, 0x00) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x00000000, but expected a valid enum tag
|
||||
@ -10,7 +10,7 @@ LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchec
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/alloc.rs:15:1
|
||||
--> $DIR/alloc.rs:16:1
|
||||
|
|
||||
LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unchecked(9, 3) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x00000003, but expected a valid enum tag
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/alloc.rs:11:1
|
||||
--> $DIR/alloc.rs:12:1
|
||||
|
|
||||
LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchecked(0x1000, 0x00) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x0000000000000000, but expected a valid enum tag
|
||||
@ -10,7 +10,7 @@ LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchec
|
||||
}
|
||||
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/alloc.rs:15:1
|
||||
--> $DIR/alloc.rs:16:1
|
||||
|
|
||||
LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unchecked(9, 3) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x0000000000000003, but expected a valid enum tag
|
||||
|
@ -2,6 +2,7 @@
|
||||
// Strip out raw byte dumps to make comparison platform-independent:
|
||||
// normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
|
||||
// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP"
|
||||
// ignore-debug debug assertions catch some UB too early
|
||||
use std::alloc::Layout;
|
||||
|
||||
// ok
|
||||
|
@ -1,4 +1,5 @@
|
||||
// compile-flags: -Z print-type-sizes --crate-type=lib
|
||||
// ignore-debug debug assertions will print more types
|
||||
// build-pass
|
||||
// ignore-pass
|
||||
// ^-- needed because `--pass check` does not emit the output needed.
|
||||
|
Loading…
x
Reference in New Issue
Block a user