Enum rustc_borrowck::ProjectionElem [−][src]
pub(crate) enum ProjectionElem<V, T> {
Deref,
Field(Field, T),
Index(V),
ConstantIndex {
offset: u64,
min_length: u64,
from_end: bool,
},
Subslice {
from: u64,
to: u64,
from_end: bool,
},
Downcast(Option<Symbol>, VariantIdx),
}Variants
Deref
Field(Field, T)
Index(V)
ConstantIndex
Fields
offset: u64index or -index (in Python terms), depending on from_end
min_length: u64The thing being indexed must be at least this long. For arrays this is always the exact length.
from_end: boolCounting backwards from end? This is always false when indexing an array.
These indices are generated by slice patterns. Easiest to explain by example:
[X, _, .._, _, _] => { offset: 0, min_length: 4, from_end: false },
[_, X, .._, _, _] => { offset: 1, min_length: 4, from_end: false },
[_, _, .._, X, _] => { offset: 2, min_length: 4, from_end: true },
[_, _, .._, _, X] => { offset: 1, min_length: 4, from_end: true },Subslice
Fields
from: u64to: u64from_end: boolWhether to counts from the start or end of the array/slice.
For PlaceElems this is true if and only if the base is a slice.
For ProjectionKind, this can also be true for arrays.
These indices are generated by slice patterns.
If from_end is true slice[from..slice.len() - to].
Otherwise array[from..to].
Downcast(Option<Symbol>, VariantIdx)
“Downcast” to a variant of an ADT. Currently, we only introduce this for ADTs with more than one variant. It may be better to just introduce it always, or always for enums.
The included Symbol is the name of the variant, used for printing MIR.
Auto Trait Implementations
impl<V, T> RefUnwindSafe for ProjectionElem<V, T> where
T: RefUnwindSafe,
V: RefUnwindSafe,
impl<V, T> Send for ProjectionElem<V, T> where
T: Send,
V: Send,
impl<V, T> Sync for ProjectionElem<V, T> where
T: Sync,
V: Sync,
impl<V, T> Unpin for ProjectionElem<V, T> where
T: Unpin,
V: Unpin,
impl<V, T> UnwindSafe for ProjectionElem<V, T> where
T: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn subst_spanned(
self,
tcx: TyCtxt<'tcx>,
substs: &[GenericArg<'tcx>],
span: Option<Span>
) -> T
Layout
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.