pub enum ProjectionElem {
Deref,
Field(FieldProjKind, FieldId),
Index {
offset: Operand,
from_end: bool,
ty: Ty,
},
Subslice {
from: Operand,
to: Operand,
from_end: bool,
ty: Ty,
},
}
Expand description
Note that we don’t have the equivalent of “downcasts”.
Downcasts are actually necessary, for instance when initializing enumeration
values: the value is initially Bottom
, and we need a way of knowing the
variant.
For example:
((_0 as Right).0: T2) = move _1;
In MIR, downcasts always happen before field projections: in our internal
language, we thus merge downcasts and field projections.
Variants§
Deref
Dereference a shared/mutable reference, a box, or a raw pointer.
Field(FieldProjKind, FieldId)
Projection from ADTs (variants, structures). We allow projections to be used as left-values and right-values. We should never have projections to fields of symbolic variants (they should have been expanded before through a match).
Index
MIR imposes that the argument to an index projection be a local variable, meaning that even constant indices into arrays are let-bound as separate variables. We eliminate this variant in a micro-pass.
Subslice
Take a subslice of a slice or array. If from_end
is true
this is
slice[from..slice.len() - to]
, otherwise this is slice[from..to]
.
We eliminate this variant in a micro-pass.
Implementations§
source§impl ProjectionElem
impl ProjectionElem
pub fn as_deref_mut(&mut self) -> Option<()>
pub fn as_field_mut(&mut self) -> Option<(&mut FieldProjKind, &mut FieldId)>
pub fn as_index_mut(&mut self) -> Option<(&mut Operand, &mut bool, &mut Ty)>
pub fn as_subslice_mut( &mut self, ) -> Option<(&mut Operand, &mut Operand, &mut bool, &mut Ty)>
source§impl ProjectionElem
impl ProjectionElem
pub fn variant_name(&self) -> &'static str
Trait Implementations§
source§impl Clone for ProjectionElem
impl Clone for ProjectionElem
source§fn clone(&self) -> ProjectionElem
fn clone(&self) -> ProjectionElem
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ProjectionElem
impl Debug for ProjectionElem
source§impl<'de> Deserialize<'de> for ProjectionElem
impl<'de> Deserialize<'de> for ProjectionElem
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl DriveMut for ProjectionElem
impl DriveMut for ProjectionElem
source§impl PartialEq for ProjectionElem
impl PartialEq for ProjectionElem
source§impl Serialize for ProjectionElem
impl Serialize for ProjectionElem
impl Eq for ProjectionElem
impl StructuralPartialEq for ProjectionElem
Auto Trait Implementations§
impl Freeze for ProjectionElem
impl RefUnwindSafe for ProjectionElem
impl Send for ProjectionElem
impl Sync for ProjectionElem
impl Unpin for ProjectionElem
impl UnwindSafe for ProjectionElem
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
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<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
§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