remove now-unused ScalarMaybeUninit

This commit is contained in:
Ralf Jung 2022-08-01 21:40:29 -04:00
parent 30fa931f92
commit 62b6a8b7b8
2 changed files with 1 additions and 134 deletions

View File

@ -124,7 +124,7 @@ pub use self::error::{
UninitBytesAccess, UnsupportedOpInfo,
};
pub use self::value::{get_slice_bytes, ConstAlloc, ConstValue, Scalar, ScalarMaybeUninit};
pub use self::value::{get_slice_bytes, ConstAlloc, ConstValue, Scalar};
pub use self::allocation::{
alloc_range, AllocRange, Allocation, ConstAllocation, InitChunk, InitChunkIter, InitMask,

View File

@ -504,139 +504,6 @@ impl<'tcx, Prov: Provenance> Scalar<Prov> {
}
}
#[derive(Clone, Copy, Eq, PartialEq, TyEncodable, TyDecodable, HashStable, Hash)]
pub enum ScalarMaybeUninit<Prov = AllocId> {
Scalar(Scalar<Prov>),
Uninit,
}
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
static_assert_size!(ScalarMaybeUninit, 24);
impl<Prov> From<Scalar<Prov>> for ScalarMaybeUninit<Prov> {
#[inline(always)]
fn from(s: Scalar<Prov>) -> Self {
ScalarMaybeUninit::Scalar(s)
}
}
// We want the `Debug` output to be readable as it is used by `derive(Debug)` for
// all the Miri types.
impl<Prov: Provenance> fmt::Debug for ScalarMaybeUninit<Prov> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ScalarMaybeUninit::Uninit => write!(f, "<uninitialized>"),
ScalarMaybeUninit::Scalar(s) => write!(f, "{:?}", s),
}
}
}
impl<Prov: Provenance> fmt::LowerHex for ScalarMaybeUninit<Prov> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ScalarMaybeUninit::Uninit => write!(f, "uninitialized bytes"),
ScalarMaybeUninit::Scalar(s) => write!(f, "{:x}", s),
}
}
}
impl<Prov> ScalarMaybeUninit<Prov> {
#[inline]
pub fn from_pointer(ptr: Pointer<Prov>, cx: &impl HasDataLayout) -> Self {
ScalarMaybeUninit::Scalar(Scalar::from_pointer(ptr, cx))
}
#[inline]
pub fn from_maybe_pointer(ptr: Pointer<Option<Prov>>, cx: &impl HasDataLayout) -> Self {
ScalarMaybeUninit::Scalar(Scalar::from_maybe_pointer(ptr, cx))
}
#[inline]
pub fn check_init<'tcx>(self) -> InterpResult<'tcx, Scalar<Prov>> {
match self {
ScalarMaybeUninit::Scalar(scalar) => Ok(scalar),
ScalarMaybeUninit::Uninit => throw_ub!(InvalidUninitBytes(None)),
}
}
}
impl<'tcx, Prov: Provenance> ScalarMaybeUninit<Prov> {
#[inline(always)]
pub fn to_pointer(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, Pointer<Option<Prov>>> {
self.check_init()?.to_pointer(cx)
}
#[inline(always)]
pub fn to_bool(self) -> InterpResult<'tcx, bool> {
self.check_init()?.to_bool()
}
#[inline(always)]
pub fn to_char(self) -> InterpResult<'tcx, char> {
self.check_init()?.to_char()
}
#[inline(always)]
pub fn to_f32(self) -> InterpResult<'tcx, Single> {
self.check_init()?.to_f32()
}
#[inline(always)]
pub fn to_f64(self) -> InterpResult<'tcx, Double> {
self.check_init()?.to_f64()
}
#[inline(always)]
pub fn to_u8(self) -> InterpResult<'tcx, u8> {
self.check_init()?.to_u8()
}
#[inline(always)]
pub fn to_u16(self) -> InterpResult<'tcx, u16> {
self.check_init()?.to_u16()
}
#[inline(always)]
pub fn to_u32(self) -> InterpResult<'tcx, u32> {
self.check_init()?.to_u32()
}
#[inline(always)]
pub fn to_u64(self) -> InterpResult<'tcx, u64> {
self.check_init()?.to_u64()
}
#[inline(always)]
pub fn to_machine_usize(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, u64> {
self.check_init()?.to_machine_usize(cx)
}
#[inline(always)]
pub fn to_i8(self) -> InterpResult<'tcx, i8> {
self.check_init()?.to_i8()
}
#[inline(always)]
pub fn to_i16(self) -> InterpResult<'tcx, i16> {
self.check_init()?.to_i16()
}
#[inline(always)]
pub fn to_i32(self) -> InterpResult<'tcx, i32> {
self.check_init()?.to_i32()
}
#[inline(always)]
pub fn to_i64(self) -> InterpResult<'tcx, i64> {
self.check_init()?.to_i64()
}
#[inline(always)]
pub fn to_machine_isize(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, i64> {
self.check_init()?.to_machine_isize(cx)
}
}
/// Gets the bytes of a constant slice value.
pub fn get_slice_bytes<'tcx>(cx: &impl HasDataLayout, val: ConstValue<'tcx>) -> &'tcx [u8] {
if let ConstValue::Slice { data, start, end } = val {