[][src]Enum rustc_middle::mir::Operand

pub enum Operand<'tcx> {
    Copy(Place<'tcx>),
    Move(Place<'tcx>),
    Constant(Box<Constant<'tcx>>),
}

These are values that can appear inside an rvalue. They are intentionally limited to prevent rvalues from being nested in one another.

Variants

Copy(Place<'tcx>)

Copy: The value must be available for use afterwards.

This implies that the type of the place must be Copy; this is true by construction during build, but also checked by the MIR type checker.

Move(Place<'tcx>)

Move: The value (including old borrows of it) will not be used again.

Safe for values of all types (modulo future developments towards ?Move). Correct usage patterns are enforced by the borrow checker for safe code. Copy may be converted to Move to enable "last-use" optimizations.

Constant(Box<Constant<'tcx>>)

Synthesizes a constant value.

Implementations

impl<'tcx> Operand<'tcx>[src]

pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx> where
    D: HasLocalDecls<'tcx>, 
[src]

impl<'tcx> Operand<'tcx>[src]

pub fn function_handle(
    tcx: TyCtxt<'tcx>,
    def_id: DefId,
    substs: SubstsRef<'tcx>,
    span: Span
) -> Self
[src]

Convenience helper to make a constant that refers to the fn with given DefId and substs. Since this is used to synthesize MIR, assumes user_ty is None.

pub fn is_move(&self) -> bool[src]

pub fn const_from_scalar(
    tcx: TyCtxt<'tcx>,
    ty: Ty<'tcx>,
    val: Scalar,
    span: Span
) -> Operand<'tcx>
[src]

Convenience helper to make a literal-like constant from a given scalar value. Since this is used to synthesize MIR, assumes user_ty is None.

pub fn to_copy(&self) -> Self[src]

pub fn place(&self) -> Option<Place<'tcx>>[src]

Returns the Place that is the target of this Operand, or None if this Operand is a constant.

pub fn constant(&self) -> Option<&Constant<'tcx>>[src]

Returns the Constant that is the target of this Operand, or None if this Operand is a place.

Trait Implementations

impl<'tcx> Clone for Operand<'tcx>[src]

impl<'tcx> Debug for Operand<'tcx>[src]

impl<'tcx, __D: TyDecoder<'tcx>> Decodable<__D> for Operand<'tcx>[src]

impl<'tcx, __E: TyEncoder<'tcx>> Encodable<__E> for Operand<'tcx>[src]

impl<'tcx, '__ctx> HashStable<StableHashingContext<'__ctx>> for Operand<'tcx>[src]

impl<'tcx> PartialEq<Operand<'tcx>> for Operand<'tcx>[src]

impl<'tcx> StructuralPartialEq for Operand<'tcx>[src]

impl<'tcx> TypeFoldable<'tcx> for Operand<'tcx>[src]

Auto Trait Implementations

impl<'tcx> !RefUnwindSafe for Operand<'tcx>

impl<'tcx> !Send for Operand<'tcx>

impl<'tcx> !Sync for Operand<'tcx>

impl<'tcx> Unpin for Operand<'tcx>

impl<'tcx> !UnwindSafe for Operand<'tcx>

Blanket Implementations

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

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

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

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

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

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

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

type Error = !

impl<'tcx, T> Subst<'tcx> for T where
    T: TypeFoldable<'tcx>, 
[src]

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.

impl<T> WithConstness for T[src]