Enum rustc_middle::mir::interpret::value::Scalar[][src]

pub enum Scalar<Tag = ()> {
    Int(ScalarInt),
    Ptr(Pointer<Tag>),
}

A Scalar represents an immediate, primitive value existing outside of a memory::Allocation. It is in many ways like a small chunk of a Allocation, up to 16 bytes in size. Like a range of bytes in an Allocation, a Scalar can either represent the raw bytes of a simple value or a pointer into another Allocation

Variants

Int(ScalarInt)

The raw bytes of a simple value.

Ptr(Pointer<Tag>)

A pointer into an Allocation. An Allocation in the memory module has a list of relocations, but a Scalar is only large enough to contain one, so we just represent the relocation and its associated offset together as a Pointer here.

Implementations

impl Scalar<()>[src]

pub fn with_tag<Tag>(self, new_tag: Tag) -> Scalar<Tag>[src]

Tag this scalar with new_tag if it is a pointer, leave it unchanged otherwise.

Used by MemPlace::replace_tag.

impl<'tcx, Tag> Scalar<Tag>[src]

pub const ZST: Self[src]

pub fn erase_tag(self) -> Scalar[src]

Erase the tag from the scalar, if any.

Used by error reporting code to avoid having the error type depend on Tag.

pub fn null_ptr(cx: &impl HasDataLayout) -> Self[src]

fn ptr_op(
    self,
    dl: &TargetDataLayout,
    f_int: impl FnOnce(u64) -> InterpResult<'tcx, u64>,
    f_ptr: impl FnOnce(Pointer<Tag>) -> InterpResult<'tcx, Pointer<Tag>>
) -> InterpResult<'tcx, Self>
[src]

pub fn ptr_offset(
    self,
    i: Size,
    cx: &impl HasDataLayout
) -> InterpResult<'tcx, Self>
[src]

pub fn ptr_wrapping_offset(self, i: Size, cx: &impl HasDataLayout) -> Self[src]

pub fn ptr_signed_offset(
    self,
    i: i64,
    cx: &impl HasDataLayout
) -> InterpResult<'tcx, Self>
[src]

pub fn ptr_wrapping_signed_offset(self, i: i64, cx: &impl HasDataLayout) -> Self[src]

pub fn from_bool(b: bool) -> Self[src]

pub fn from_char(c: char) -> Self[src]

pub fn try_from_uint(i: impl Into<u128>, size: Size) -> Option<Self>[src]

pub fn from_uint(i: impl Into<u128>, size: Size) -> Self[src]

pub fn from_u8(i: u8) -> Self[src]

pub fn from_u16(i: u16) -> Self[src]

pub fn from_u32(i: u32) -> Self[src]

pub fn from_u64(i: u64) -> Self[src]

pub fn from_machine_usize(i: u64, cx: &impl HasDataLayout) -> Self[src]

pub fn try_from_int(i: impl Into<i128>, size: Size) -> Option<Self>[src]

pub fn from_int(i: impl Into<i128>, size: Size) -> Self[src]

pub fn from_i32(i: i32) -> Self[src]

pub fn from_i64(i: i64) -> Self[src]

pub fn from_machine_isize(i: i64, cx: &impl HasDataLayout) -> Self[src]

pub fn from_f32(f: Single) -> Self[src]

pub fn from_f64(f: Double) -> Self[src]

pub fn to_bits_or_ptr(
    self,
    target_size: Size,
    cx: &impl HasDataLayout
) -> Result<u128, Pointer<Tag>>
[src]

This is very rarely the method you want! You should dispatch on the type and use force_bits/assert_bits/force_ptr/assert_ptr. This method only exists for the benefit of low-level memory operations as well as the implementation of the force_* methods.

fn to_bits(self, target_size: Size) -> InterpResult<'tcx, u128>[src]

This method is intentionally private! It is just a helper for other methods in this file.

pub fn assert_bits(self, target_size: Size) -> u128[src]

pub fn assert_int(self) -> ScalarInt[src]

pub fn assert_ptr(self) -> Pointer<Tag>[src]

pub fn is_bits(self) -> bool[src]

Do not call this method! Dispatch based on the type instead.

pub fn is_ptr(self) -> bool[src]

Do not call this method! Dispatch based on the type instead.

pub fn to_bool(self) -> InterpResult<'tcx, bool>[src]

pub fn to_char(self) -> InterpResult<'tcx, char>[src]

fn to_unsigned_with_bit_width(self, bits: u64) -> InterpResult<'static, u128>[src]

pub fn to_u8(self) -> InterpResult<'static, u8>[src]

Converts the scalar to produce an u8. Fails if the scalar is a pointer.

pub fn to_u16(self) -> InterpResult<'static, u16>[src]

Converts the scalar to produce an u16. Fails if the scalar is a pointer.

pub fn to_u32(self) -> InterpResult<'static, u32>[src]

Converts the scalar to produce an u32. Fails if the scalar is a pointer.

pub fn to_u64(self) -> InterpResult<'static, u64>[src]

Converts the scalar to produce an u64. Fails if the scalar is a pointer.

pub fn to_u128(self) -> InterpResult<'static, u128>[src]

Converts the scalar to produce an u128. Fails if the scalar is a pointer.

pub fn to_machine_usize(
    self,
    cx: &impl HasDataLayout
) -> InterpResult<'static, u64>
[src]

fn to_signed_with_bit_width(self, bits: u64) -> InterpResult<'static, i128>[src]

pub fn to_i8(self) -> InterpResult<'static, i8>[src]

Converts the scalar to produce an i8. Fails if the scalar is a pointer.

pub fn to_i16(self) -> InterpResult<'static, i16>[src]

Converts the scalar to produce an i16. Fails if the scalar is a pointer.

pub fn to_i32(self) -> InterpResult<'static, i32>[src]

Converts the scalar to produce an i32. Fails if the scalar is a pointer.

pub fn to_i64(self) -> InterpResult<'static, i64>[src]

Converts the scalar to produce an i64. Fails if the scalar is a pointer.

pub fn to_i128(self) -> InterpResult<'static, i128>[src]

Converts the scalar to produce an i128. Fails if the scalar is a pointer.

pub fn to_machine_isize(
    self,
    cx: &impl HasDataLayout
) -> InterpResult<'static, i64>
[src]

pub fn to_f32(self) -> InterpResult<'static, Single>[src]

pub fn to_f64(self) -> InterpResult<'static, Double>[src]

Trait Implementations

impl<Tag: Clone> Clone for Scalar<Tag>[src]

fn clone(&self) -> Scalar<Tag>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<Tag: Debug> Debug for Scalar<Tag>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<'tcx, Tag, __D: TyDecoder<'tcx>> Decodable<__D> for Scalar<Tag> where
    Tag: Decodable<__D>, 
[src]

fn decode(__decoder: &mut __D) -> Result<Self, <__D as Decoder>::Error>[src]

impl<Tag: Debug> Display for Scalar<Tag>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<'tcx, Tag, __E: TyEncoder<'tcx>> Encodable<__E> for Scalar<Tag> where
    Tag: Encodable<__E>, 
[src]

fn encode(&self, __encoder: &mut __E) -> Result<(), <__E as Encoder>::Error>[src]

impl<Tag> From<IeeeFloat<DoubleS>> for Scalar<Tag>[src]

fn from(f: Double) -> Self[src]

Performs the conversion.

impl<Tag> From<IeeeFloat<SingleS>> for Scalar<Tag>[src]

fn from(f: Single) -> Self[src]

Performs the conversion.

impl<Tag> From<Pointer<Tag>> for Scalar<Tag>[src]

fn from(ptr: Pointer<Tag>) -> Self[src]

Performs the conversion.

impl<'tcx> From<Scalar<()>> for ConstValue<'tcx>[src]

fn from(s: Scalar) -> Self[src]

Performs the conversion.

impl<Tag> From<Scalar<Tag>> for ScalarMaybeUninit<Tag>[src]

fn from(s: Scalar<Tag>) -> Self[src]

Performs the conversion.

impl<Tag> From<ScalarInt> for Scalar<Tag>[src]

fn from(ptr: ScalarInt) -> Self[src]

Performs the conversion.

impl<Tag: Hash> Hash for Scalar<Tag>[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl<'__ctx, Tag> HashStable<StableHashingContext<'__ctx>> for Scalar<Tag> where
    Tag: HashStable<StableHashingContext<'__ctx>>, 
[src]

fn hash_stable(
    &self,
    __hcx: &mut StableHashingContext<'__ctx>,
    __hasher: &mut StableHasher
)
[src]

impl<Tag: Ord> Ord for Scalar<Tag>[src]

fn cmp(&self, other: &Scalar<Tag>) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl<Tag: PartialEq> PartialEq<Scalar<Tag>> for Scalar<Tag>[src]

fn eq(&self, other: &Scalar<Tag>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Scalar<Tag>) -> bool[src]

This method tests for !=.

impl<Tag: PartialOrd> PartialOrd<Scalar<Tag>> for Scalar<Tag>[src]

fn partial_cmp(&self, other: &Scalar<Tag>) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<Tag: Copy> Copy for Scalar<Tag>[src]

impl<Tag: Eq> Eq for Scalar<Tag>[src]

impl<Tag> StructuralEq for Scalar<Tag>[src]

impl<Tag> StructuralPartialEq for Scalar<Tag>[src]

Auto Trait Implementations

impl<Tag> RefUnwindSafe for Scalar<Tag> where
    Tag: RefUnwindSafe

impl<Tag> Send for Scalar<Tag> where
    Tag: Send

impl<Tag> Sync for Scalar<Tag> where
    Tag: Sync

impl<Tag> Unpin for Scalar<Tag> where
    Tag: Unpin

impl<Tag> UnwindSafe for Scalar<Tag> where
    Tag: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<'tcx, T> ArenaAllocatable<'tcx, ()> for T where
    T: Copy
[src]

pub fn allocate_on(Self, &'a Arena<'tcx>) -> &'a mut T[src]

pub fn allocate_from_iter(
    &'a Arena<'tcx>,
    impl IntoIterator<Item = T>
) -> &'a mut [T]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> MaybeResult<T> for T[src]

type Error = !

pub fn from(Result<T, <T as MaybeResult<T>>::Error>) -> T[src]

pub fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<T> WithConstness for T[src]

fn with_constness(self, constness: Constness) -> ConstnessAnd<Self>[src]

fn with_const(self) -> ConstnessAnd<Self>[src]

fn without_const(self) -> ConstnessAnd<Self>[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized
[src]