Struct rustc_pattern_analysis::pat::DeconstructedPat
source · pub struct DeconstructedPat<Cx: TypeCx> {
ctor: Constructor<Cx>,
fields: Vec<DeconstructedPat<Cx>>,
ty: Cx::Ty,
data: Option<Cx::PatData>,
pub(crate) uid: PatId,
}Expand description
Values and patterns can be represented as a constructor applied to some fields. This represents
a pattern in this form. A DeconstructedPat will almost always come from user input; the only
exception are some Wildcards introduced during pattern lowering.
Note that the number of fields may not match the fields declared in the original struct/variant.
This happens if a private or non_exhaustive field is uninhabited, because the code mustn’t
observe that it is uninhabited. In that case that field is not included in fields. Care must
be taken when converting to/from thir::Pat.
Fields§
§ctor: Constructor<Cx>§fields: Vec<DeconstructedPat<Cx>>§ty: Cx::Ty§data: Option<Cx::PatData>Extra data to store in a pattern. None if the pattern is a wildcard that does not
correspond to a user-supplied pattern.
uid: PatIdGlobally-unique id used to track usefulness at the level of subpatterns.
Implementations§
source§impl<Cx: TypeCx> DeconstructedPat<Cx>
impl<Cx: TypeCx> DeconstructedPat<Cx>
pub fn wildcard(ty: Cx::Ty) -> Self
pub fn new( ctor: Constructor<Cx>, fields: Vec<DeconstructedPat<Cx>>, ty: Cx::Ty, data: Cx::PatData ) -> Self
pub(crate) fn is_or_pat(&self) -> bool
pub fn ctor(&self) -> &Constructor<Cx>
pub fn ty(&self) -> &Cx::Ty
sourcepub fn data(&self) -> Option<&Cx::PatData>
pub fn data(&self) -> Option<&Cx::PatData>
Returns the extra data stored in a pattern. Returns None if the pattern is a wildcard that
does not correspond to a user-supplied pattern.
pub fn iter_fields<'a>( &'a self ) -> impl Iterator<Item = &'a DeconstructedPat<Cx>>
sourcepub(crate) fn specialize<'a>(
&'a self,
other_ctor: &Constructor<Cx>,
ctor_arity: usize
) -> SmallVec<[PatOrWild<'a, Cx>; 2]>
pub(crate) fn specialize<'a>( &'a self, other_ctor: &Constructor<Cx>, 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.
Trait Implementations§
Auto Trait Implementations§
impl<Cx> DynSend for DeconstructedPat<Cx>
impl<Cx> DynSync for DeconstructedPat<Cx>
impl<Cx> RefUnwindSafe for DeconstructedPat<Cx>where
<Cx as TypeCx>::PatData: RefUnwindSafe,
<Cx as TypeCx>::StrLit: RefUnwindSafe,
<Cx as TypeCx>::Ty: RefUnwindSafe,
<Cx as TypeCx>::VariantIdx: RefUnwindSafe,
impl<Cx> Send for DeconstructedPat<Cx>
impl<Cx> Sync for DeconstructedPat<Cx>
impl<Cx> Unpin for DeconstructedPat<Cx>
impl<Cx> UnwindSafe for DeconstructedPat<Cx>where
<Cx as TypeCx>::PatData: UnwindSafe,
<Cx as TypeCx>::StrLit: UnwindSafe,
<Cx as TypeCx>::Ty: UnwindSafe,
<Cx as TypeCx>::VariantIdx: UnwindSafe,
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, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§impl<T> Filterable for T
impl<T> Filterable for T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<P> IntoQueryParam<P> for P
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<'tcx, T> ToPredicate<'tcx, T> for T
impl<'tcx, T> ToPredicate<'tcx, T> for T
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> T
source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed ) -> T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for 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.