Enum rustc_smir::stable_mir::mir::body::Rvalue
source · pub enum Rvalue {
Show 13 variants
AddressOf(Mutability, Place),
BinaryOp(BinOp, Operand, Operand),
Cast(CastKind, Operand, Ty),
CheckedBinaryOp(BinOp, Operand, Operand),
CopyForDeref(Place),
Discriminant(Place),
Len(Place),
Ref(Opaque, BorrowKind, Place),
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).
BinaryOp(BinOp, Operand, Operand)
Offsethas the same semantics asoffset, except that the second parameter may be ausizeas well.- The comparison operations accept
bools,chars, signed or unsigned integers, floats, raw pointers, or function pointers and return abool. 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 of type
discriminant_ty. 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; use discriminant_for_variant to convert.
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(Opaque, BorrowKind, Place)
Creates a reference to the place.
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
Trait Implementations§
Auto Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
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:88 bytes
Size for each variant:
AddressOf: 39 bytesBinaryOp: 87 bytesCast: 55 bytesCheckedBinaryOp: 87 bytesCopyForDeref: 39 bytesDiscriminant: 39 bytesLen: 39 bytesRef: 63 bytesShallowInitBox: 55 bytesThreadLocalRef: 15 bytesNullaryOp: 47 bytesUnaryOp: 47 bytesUse: 47 bytes