Enum stable_mir::mir::Rvalue

source ·
pub enum Rvalue {
Show 15 variants AddressOf(Mutability, Place), Aggregate(AggregateKind, Vec<Operand>), BinaryOp(BinOp, Operand, Operand), Cast(CastKind, Operand, Ty), CheckedBinaryOp(BinOp, Operand, Operand), CopyForDeref(Place), Discriminant(Place), Len(Place), Ref(Region, BorrowKind, Place), Repeat(Operand, TyConst), ShallowInitBox(Operand, Ty), ThreadLocalRef(CrateItem), NullaryOp(NullOp, Ty), UnaryOp(UnOp, Operand), Use(Operand),
}

Variants§

§

AddressOf(Mutability, Place)

Creates a pointer with the indicated mutability to the place.

This is generated by pointer casts like &v as *const _ or raw address of expressions like &raw v or addr_of!(v).

§

Aggregate(AggregateKind, Vec<Operand>)

Creates an aggregate value, like a tuple or struct.

This is needed because dataflow analysis needs to distinguish dest = Foo { x: ..., y: ... } from dest.x = ...; dest.y = ...; in the case that Foo has a destructor.

Disallowed after deaggregation for all aggregate kinds except Array and Coroutine. After coroutine lowering, Coroutine aggregate kinds are disallowed too.

§

BinaryOp(BinOp, Operand, Operand)

  • Offset has the same semantics as <*const T>::offset, except that the second parameter may be a usize as well.
  • The comparison operations accept bools, chars, signed or unsigned integers, floats, raw pointers, or function pointers and return a bool. The types of the operands must be matching, up to the usual caveat of the lifetimes in function pointers.
  • Left and right shift operations accept signed or unsigned integers not necessarily of the same type and return a value of the same type as their LHS. Like in Rust, the RHS is truncated as needed.
  • The Bit* operations accept signed integers, unsigned integers, or bools with matching types and return a value of that type.
  • The remaining operations accept signed integers, unsigned integers, or floats with matching types and return a value of that type.
§

Cast(CastKind, Operand, Ty)

Performs essentially all of the casts that can be performed via as.

This allows for casts from/to a variety of types.

§

CheckedBinaryOp(BinOp, Operand, Operand)

Same as BinaryOp, but yields (T, bool) with a bool indicating an error condition.

For addition, subtraction, and multiplication on integers the error condition is set when the infinite precision result would not be equal to the actual result.

§

CopyForDeref(Place)

A CopyForDeref is equivalent to a read from a place. When such a read happens, it is guaranteed that the only use of the returned value is a deref operation, immediately followed by one or more projections.

§

Discriminant(Place)

Computes the discriminant of the place, returning it as an integer. Returns zero for types without discriminant.

The validity requirements for the underlying value are undecided for this rvalue, see #91095. Note too that the value of the discriminant is not the same thing as the variant index;

§

Len(Place)

Yields the length of the place, as a usize.

If the type of the place is an array, this is the array length. For slices ([T], not &[T]) this accesses the place’s metadata to determine the length. This rvalue is ill-formed for places of other types.

§

Ref(Region, BorrowKind, Place)

Creates a reference to the place.

§

Repeat(Operand, TyConst)

Creates an array where each element is the value of the operand.

This is the cause of a bug in the case where the repetition count is zero because the value is not dropped, see #74836.

Corresponds to source code like [x; 32].

§

ShallowInitBox(Operand, Ty)

Transmutes a *mut u8 into shallow-initialized Box<T>.

This is different from a normal transmute because dataflow analysis will treat the box as initialized but its content as uninitialized. Like other pointer casts, this in general affects alias analysis.

§

ThreadLocalRef(CrateItem)

Creates a pointer/reference to the given thread local.

The yielded type is a *mut T if the static is mutable, otherwise if the static is extern a *const T, and if neither of those apply a &T.

Note: This is a runtime operation that actually executes code and is in this sense more like a function call. Also, eliminating dead stores of this rvalue causes fn main() {} to SIGILL for some reason that I (JakobDegen) never got a chance to look into.

Needs clarification: Are there weird additional semantics here related to the runtime nature of this operation?

§

NullaryOp(NullOp, Ty)

Computes a value as described by the operation.

§

UnaryOp(UnOp, Operand)

Exactly like BinaryOp, but less operands.

Also does two’s-complement arithmetic. Negation requires a signed integer or a float; bitwise not requires a signed integer, unsigned integer, or bool. Both operation kinds return a value with the same type as their operand.

§

Use(Operand)

Yields the operand unchanged

Implementations§

source§

impl Rvalue

source

pub fn ty(&self, locals: &[LocalDecl]) -> Result<Ty, Error>

Trait Implementations§

source§

impl Clone for Rvalue

source§

fn clone(&self) -> Rvalue

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Rvalue

source§

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

Formats the value using the given formatter. Read more
source§

impl PartialEq for Rvalue

source§

fn eq(&self, other: &Rvalue) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Rvalue

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Rvalue

source§

impl StructuralPartialEq for Rvalue

Auto Trait Implementations§

§

impl Freeze for Rvalue

§

impl RefUnwindSafe for Rvalue

§

impl Send for Rvalue

§

impl Sync for Rvalue

§

impl Unpin for Rvalue

§

impl UnwindSafe for Rvalue

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 248 bytes

Size for each variant:

  • AddressOf: 39 bytes
  • Aggregate: 103 bytes
  • BinaryOp: 247 bytes
  • Cast: 135 bytes
  • CheckedBinaryOp: 247 bytes
  • CopyForDeref: 39 bytes
  • Discriminant: 39 bytes
  • Len: 39 bytes
  • Ref: 95 bytes
  • Repeat: 207 bytes
  • ShallowInitBox: 135 bytes
  • ThreadLocalRef: 15 bytes
  • NullaryOp: 39 bytes
  • UnaryOp: 127 bytes
  • Use: 127 bytes