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

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

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

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

Used by MemPlace::replace_tag.

Erase the tag from the scalar, if any.

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

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.

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

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

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

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

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

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

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

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

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

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

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

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

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

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

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

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

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=.

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

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

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

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

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

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

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Layout

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.