pub enum Operand {
Copy(Place),
Move(Place),
Constant(Const<Interner>),
Static(StaticId),
}
Expand description
An operand in MIR represents a “value” in Rust, the definition of which is undecided and part of the memory model. One proposal for a definition of values can be found on UCG.
The most common way to create values is via loading a place. Loading a place is an operation which reads the memory of the place and converts it to a value. This is a fundamentally typed operation. The nature of the value produced depends on the type of the conversion. Furthermore, there may be other effects: if the type has a validity constraint loading the place might be UB if the validity constraint is not met.
Needs clarification: Ralf proposes that loading a place not have side-effects. This is what is implemented in miri today. Are these the semantics we want for MIR? Is this something we can even decide without knowing more about Rust’s memory model?
Needs clarification: Is loading a place that has its variant index set well-formed? Miri currently implements it, but it seems like this may be something to check against in the validator.
Variants§
Copy(Place)
Creates a value by loading the given place.
Before drop elaboration, the type of the place must be Copy
. After drop elaboration there
is no such requirement.
Move(Place)
Creates a value by performing loading the place, just like the Copy
operand.
This may additionally overwrite the place with uninit
bytes, depending on how we decide
in UCG#188. You should not emit MIR that may attempt a subsequent second load of this
place without first re-initializing it.
Constant(Const<Interner>)
Constants are already semantically values, and remain unchanged.
Static(StaticId)
NON STANDARD: This kind of operand returns an immutable reference to that static memory. Rustc
handles it with the Constant
variant somehow.
Trait Implementations§
impl Eq for Operand
impl StructuralPartialEq for Operand
Auto Trait Implementations§
impl Freeze for Operand
impl RefUnwindSafe for Operand
impl Send for Operand
impl Sync for Operand
impl Unpin for Operand
impl UnwindSafe for Operand
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
§impl<T> Cast for T
impl<T> Cast for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more