rustc_pattern_analysis::rustc

Type Alias DeconstructedPat

Source
pub type DeconstructedPat<'p, 'tcx> = DeconstructedPat<RustcPatCtxt<'p, 'tcx>>;

Aliased Type§

struct DeconstructedPat<'p, 'tcx> {
    ctor: Constructor<RustcPatCtxt<'p, 'tcx>>,
    fields: Vec<IndexedPat<RustcPatCtxt<'p, 'tcx>>>,
    arity: usize,
    ty: RevealedTy<'tcx>,
    data: &'p Pat<'tcx>,
    pub(crate) uid: PatId,
}

Fields§

§ctor: Constructor<RustcPatCtxt<'p, 'tcx>>§fields: Vec<IndexedPat<RustcPatCtxt<'p, 'tcx>>>§arity: usize

The number of fields in this pattern. E.g. if the pattern is SomeStruct { field12: true, .. } this would be the total number of fields of the struct. This is also the same as self.ctor.arity(self.ty).

§ty: RevealedTy<'tcx>§data: &'p Pat<'tcx>

Extra data to store in a pattern.

§uid: PatId

Globally-unique id used to track usefulness at the level of subpatterns.

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: 144 bytes

Implementations

Source§

impl<Cx: PatCx> DeconstructedPat<Cx>

Source

pub fn new( ctor: Constructor<Cx>, fields: Vec<IndexedPat<Cx>>, arity: usize, ty: Cx::Ty, data: Cx::PatData, ) -> Self

Source

pub fn at_index(self, idx: usize) -> IndexedPat<Cx>

Source

pub(crate) fn is_or_pat(&self) -> bool

Source

pub fn ctor(&self) -> &Constructor<Cx>

Source

pub fn ty(&self) -> &Cx::Ty

Source

pub fn data(&self) -> &Cx::PatData

Returns the extra data stored in a pattern.

Source

pub fn arity(&self) -> usize

Source

pub fn iter_fields<'a>(&'a self) -> impl Iterator<Item = &'a IndexedPat<Cx>>

Source

pub(crate) fn specialize<'a>( &'a self, other_ctor: &Constructor<Cx>, other_ctor_arity: usize, ) -> SmallVec<[PatOrWild<'a, Cx>; 2]>

Specialize this pattern with a constructor. other_ctor can be different from self.ctor, but must be covered by it.

Source

pub fn walk<'a>(&'a self, it: &mut impl FnMut(&'a Self) -> bool)

Walk top-down and call it in each place where a pattern occurs starting with the root pattern walk is called on. If it returns false then we will descend no further but siblings will be processed.

Trait Implementations

Source§

impl<Cx: PatCx> Debug for DeconstructedPat<Cx>

This is best effort and not good enough for a Display impl.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Cx: PatCx> Hash for DeconstructedPat<Cx>

Delegate to uid.

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Cx: PatCx> PartialEq for DeconstructedPat<Cx>

Delegate to uid.

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Cx: PatCx> Eq for DeconstructedPat<Cx>

Delegate to uid.