pub(crate) struct DeconstructedPat<'p, 'tcx> {
    ctor: Constructor<'tcx>,
    fields: Fields<'p, 'tcx>,
    ty: Ty<'tcx>,
    span: Span,
    reachable: Cell<bool>,
}
Expand description

Values and patterns can be represented as a constructor applied to some fields. This represents a pattern in this form. This also keeps track of whether the pattern has been found reachable during analysis. For this reason we should be careful not to clone patterns for which we care about that. Use clone_and_forget_reachability if you’re sure.

Fields§

§ctor: Constructor<'tcx>§fields: Fields<'p, 'tcx>§ty: Ty<'tcx>§span: Span§reachable: Cell<bool>

Implementations§

source§

impl<'p, 'tcx> DeconstructedPat<'p, 'tcx>

source

pub(super) fn wildcard(ty: Ty<'tcx>, span: Span) -> Self

source

pub(super) fn new( ctor: Constructor<'tcx>, fields: Fields<'p, 'tcx>, ty: Ty<'tcx>, span: Span ) -> Self

source

pub(super) fn wild_from_ctor( pcx: &PatCtxt<'_, 'p, 'tcx>, ctor: Constructor<'tcx> ) -> Self

Construct a pattern that matches everything that starts with this constructor. For example, if ctor is a Constructor::Variant for Option::Some, we get the pattern Some(_).

source

pub(super) fn clone_and_forget_reachability(&self) -> Self

Clone this value. This method emphasizes that cloning loses reachability information and should be done carefully.

source

pub(crate) fn from_pat(cx: &MatchCheckCtxt<'p, 'tcx>, pat: &Pat<'tcx>) -> Self

source

pub(crate) fn to_pat(&self, cx: &MatchCheckCtxt<'p, 'tcx>) -> Pat<'tcx>

source

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

source

pub(super) fn ctor(&self) -> &Constructor<'tcx>

source

pub(super) fn ty(&self) -> Ty<'tcx>

source

pub(super) fn span(&self) -> Span

source

pub(super) fn iter_fields<'a>( &'a self ) -> impl Iterator<Item = &'p DeconstructedPat<'p, 'tcx>> + Captures<'a>

source

pub(super) fn specialize<'a>( &'a self, pcx: &PatCtxt<'_, 'p, 'tcx>, other_ctor: &Constructor<'tcx> ) -> SmallVec<[&'p DeconstructedPat<'p, 'tcx>; 2]>

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

source

pub(super) fn set_reachable(&self)

We keep track for each pattern if it was ever reachable during the analysis. This is used with unreachable_spans to report unreachable subpatterns arising from or patterns.

source

pub(super) fn is_reachable(&self) -> bool

source

pub(super) fn unreachable_spans(&self) -> Vec<Span>

Report the spans of subpatterns that were not reachable, if any.

source

fn collect_unreachable_spans(&self, spans: &mut Vec<Span>)

Trait Implementations§

source§

impl<'p, 'tcx> Debug for DeconstructedPat<'p, 'tcx>

This is mostly copied from the Pat impl. 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

Auto Trait Implementations§

§

impl<'p, 'tcx> !RefUnwindSafe for DeconstructedPat<'p, 'tcx>

§

impl<'p, 'tcx> !Send for DeconstructedPat<'p, 'tcx>

§

impl<'p, 'tcx> !Sync for DeconstructedPat<'p, 'tcx>

§

impl<'p, 'tcx> Unpin for DeconstructedPat<'p, 'tcx>

§

impl<'p, 'tcx> !UnwindSafe for DeconstructedPat<'p, 'tcx>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

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