pub(crate) struct MatchCheckCtx<'a, 'db> {
module: ModuleId,
pub(crate) db: &'db dyn HirDatabase,
exhaustive_patterns: bool,
env: ParamEnv<'db>,
infcx: &'a InferCtxt<'db>,
}Fields§
§module: ModuleId§db: &'db dyn HirDatabase§exhaustive_patterns: bool§env: ParamEnv<'db>§infcx: &'a InferCtxt<'db>Implementations§
Source§impl<'a, 'db> MatchCheckCtx<'a, 'db>
impl<'a, 'db> MatchCheckCtx<'a, 'db>
pub(crate) fn new( module: ModuleId, infcx: &'a InferCtxt<'db>, env: ParamEnv<'db>, ) -> Self
pub(crate) fn compute_match_usefulness<'b>( &self, arms: &[MatchArm<'b, MatchCheckCtx<'a, 'db>>], scrut_ty: Ty<'db>, known_valid_scrutinee: Option<bool>, ) -> Result<UsefulnessReport<'b, Self>, ()>
fn is_uninhabited(&self, ty: Ty<'db>) -> bool
Sourcefn is_foreign_non_exhaustive(&self, adt: AdtId) -> bool
fn is_foreign_non_exhaustive(&self, adt: AdtId) -> bool
Returns whether the given ADT is from another crate declared #[non_exhaustive].
fn variant_id_for_adt( db: &'db dyn HirDatabase, ctor: &Constructor<Self>, adt: AdtId, ) -> Option<VariantId>
fn list_variant_fields( &self, ty: Ty<'db>, variant: VariantId, ) -> impl Iterator<Item = (LocalFieldId, Ty<'db>)>
pub(crate) fn lower_pat( &self, pat: &Pat<'db>, ) -> DeconstructedPat<MatchCheckCtx<'a, 'db>>
pub(crate) fn hoist_witness_pat( &self, pat: &WitnessPat<MatchCheckCtx<'a, 'db>>, ) -> Pat<'db>
Trait Implementations§
Source§impl<'a, 'db> Clone for MatchCheckCtx<'a, 'db>
impl<'a, 'db> Clone for MatchCheckCtx<'a, 'db>
Source§fn clone(&self) -> MatchCheckCtx<'a, 'db>
fn clone(&self) -> MatchCheckCtx<'a, 'db>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MatchCheckCtx<'_, '_>
impl Debug for MatchCheckCtx<'_, '_>
Source§impl<'a, 'db> PatCx for MatchCheckCtx<'a, 'db>
impl<'a, 'db> PatCx for MatchCheckCtx<'a, 'db>
Source§type VariantIdx = EnumVariantContiguousIndex
type VariantIdx = EnumVariantContiguousIndex
The index of an enum variant.
fn is_exhaustive_patterns_feature_on(&self) -> bool
Source§fn ctor_arity(&self, ctor: &Constructor<Self>, ty: &Self::Ty) -> usize
fn ctor_arity(&self, ctor: &Constructor<Self>, ty: &Self::Ty) -> usize
The number of fields for this constructor.
Source§fn ctor_sub_tys(
&self,
ctor: &Constructor<Self>,
ty: &Self::Ty,
) -> impl ExactSizeIterator<Item = (Self::Ty, PrivateUninhabitedField)>
fn ctor_sub_tys( &self, ctor: &Constructor<Self>, ty: &Self::Ty, ) -> impl ExactSizeIterator<Item = (Self::Ty, PrivateUninhabitedField)>
The types of the fields for this constructor. The result must contain
ctor_arity() fields.Source§fn ctors_for_ty(
&self,
ty: &Self::Ty,
) -> Result<ConstructorSet<Self>, Self::Error>
fn ctors_for_ty( &self, ty: &Self::Ty, ) -> Result<ConstructorSet<Self>, Self::Error>
The set of all the constructors for
ty. Read moreSource§fn write_variant_name(
f: &mut Formatter<'_>,
_ctor: &Constructor<Self>,
_ty: &Self::Ty,
) -> Result
fn write_variant_name( f: &mut Formatter<'_>, _ctor: &Constructor<Self>, _ty: &Self::Ty, ) -> Result
Write the name of the variant represented by
pat. Used for the best-effort Debug impl of
DeconstructedPat. Only invoqued when pat.ctor() is Struct | Variant(_) | UnionField.Source§fn complexity_exceeded(&self) -> Result<(), Self::Error>
fn complexity_exceeded(&self) -> Result<(), Self::Error>
The maximum pattern complexity limit was reached.
Source§fn report_mixed_deref_pat_ctors(
&self,
_deref_pat: &DeconstructedPat<MatchCheckCtx<'a, 'db>>,
_normal_pat: &DeconstructedPat<MatchCheckCtx<'a, 'db>>,
)
fn report_mixed_deref_pat_ctors( &self, _deref_pat: &DeconstructedPat<MatchCheckCtx<'a, 'db>>, _normal_pat: &DeconstructedPat<MatchCheckCtx<'a, 'db>>, )
The current implementation of deref patterns requires that they can’t match on the same
place as a normal constructor. Since this isn’t caught by type-checking, we check it in the
PatCx before running the analysis. This reports an error if the check fails.§fn exhaustive_witnesses(&self) -> bool
fn exhaustive_witnesses(&self) -> bool
Whether to ensure the non-exhaustiveness witnesses we report for a complete set. This is
false by default to avoid some exponential blowup cases such as
https://github.com/rust-lang/rust/issues/118437.§fn lint_overlapping_range_endpoints(
&self,
_pat: &DeconstructedPat<Self>,
_overlaps_on: IntRange,
_overlaps_with: &[&DeconstructedPat<Self>],
)
fn lint_overlapping_range_endpoints( &self, _pat: &DeconstructedPat<Self>, _overlaps_on: IntRange, _overlaps_with: &[&DeconstructedPat<Self>], )
Lint that the range
pat overlapped with all the ranges in overlaps_with, where the range
they overlapped over is overlaps_on. We only detect singleton overlaps.
The default implementation does nothing.§fn lint_non_contiguous_range_endpoints(
&self,
_pat: &DeconstructedPat<Self>,
_gap: IntRange,
_gapped_with: &[&DeconstructedPat<Self>],
)
fn lint_non_contiguous_range_endpoints( &self, _pat: &DeconstructedPat<Self>, _gap: IntRange, _gapped_with: &[&DeconstructedPat<Self>], )
Lint that there is a gap
gap between pat and all of gapped_with such that the gap is
not matched by another range. If gapped_with is empty, then gap is T::MAX. We only
detect singleton gaps.
The default implementation does nothing.§fn match_may_contain_deref_pats(&self) -> bool
fn match_may_contain_deref_pats(&self) -> bool
Check if we may need to perform additional deref-pattern-specific validation.
Auto Trait Implementations§
impl<'a, 'db> Freeze for MatchCheckCtx<'a, 'db>
impl<'a, 'db> !RefUnwindSafe for MatchCheckCtx<'a, 'db>
impl<'a, 'db> !Send for MatchCheckCtx<'a, 'db>
impl<'a, 'db> !Sync for MatchCheckCtx<'a, 'db>
impl<'a, 'db> Unpin for MatchCheckCtx<'a, 'db>
impl<'a, 'db> UnsafeUnpin for MatchCheckCtx<'a, 'db>
impl<'a, 'db> !UnwindSafe for MatchCheckCtx<'a, 'db>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more