Struct rustc_mir_build::thir::pattern::deconstruct_pat::DeconstructedPat [−][src]
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
pub(super) fn new(
ctor: Constructor<'tcx>,
fields: Fields<'p, 'tcx>,
ty: Ty<'tcx>,
span: Span
) -> 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(_)
.
Clone this value. This method emphasizes that cloning loses reachability information and should be done carefully.
pub(super) fn iter_fields<'a>(
&'a self
) -> impl Iterator<Item = &'p DeconstructedPat<'p, 'tcx>> + Captures<'a>
pub(super) fn specialize<'a>(
&'a self,
cx: &MatchCheckCtxt<'p, 'tcx>,
other_ctor: &Constructor<'tcx>
) -> SmallVec<[&'p DeconstructedPat<'p, 'tcx>; 2]>
pub(super) fn specialize<'a>(
&'a self,
cx: &MatchCheckCtxt<'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.
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.
Report the spans of subpatterns that were not reachable, if any.
Trait Implementations
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> where
'tcx: 'p,
impl<'p, 'tcx> !UnwindSafe for DeconstructedPat<'p, 'tcx>
Blanket Implementations
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: 104 bytes