Skip to main content

MatchCheckCtx

Struct MatchCheckCtx 

Source
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>

Source

pub(crate) fn new( module: ModuleId, infcx: &'a InferCtxt<'db>, env: ParamEnv<'db>, ) -> Self

Source

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>, ()>

Source

fn is_uninhabited(&self, ty: Ty<'db>) -> bool

Source

fn is_foreign_non_exhaustive(&self, adt: AdtId) -> bool

Returns whether the given ADT is from another crate declared #[non_exhaustive].

Source

fn variant_id_for_adt( db: &'db dyn HirDatabase, ctor: &Constructor<Self>, adt: AdtId, ) -> Option<VariantId>

Source

fn list_variant_fields( &self, ty: Ty<'db>, variant: VariantId, ) -> impl Iterator<Item = (LocalFieldId, Ty<'db>)>

Source

pub(crate) fn lower_pat( &self, pat: &Pat<'db>, ) -> DeconstructedPat<MatchCheckCtx<'a, 'db>>

Source

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>

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for MatchCheckCtx<'_, '_>

Source§

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

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

impl<'a, 'db> PatCx for MatchCheckCtx<'a, 'db>

Source§

type Error = ()

Errors that can abort analysis.
Source§

type Ty = Ty<'db>

The type of a pattern.
Source§

type VariantIdx = EnumVariantContiguousIndex

The index of an enum variant.
Source§

type StrLit = Void

A string literal
Source§

type ArmData = ()

Extra data to store in a match arm.
Source§

type PatData = ()

Extra data to store in a pattern.
Source§

fn is_exhaustive_patterns_feature_on(&self) -> bool

Source§

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)>

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>

The set of all the constructors for ty. Read more
Source§

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 bug(&self, fmt: Arguments<'_>)

Raise a bug.
Source§

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>>, )

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

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>], )

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>], )

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

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T, R> CollectAndApply<T, R> for T

§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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.

§

impl<T> IntoBox<dyn Any> for T
where T: Any,

§

fn into_box(self) -> Box<dyn Any>

Convert self into the appropriate boxed form.
Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Lookup<T> for T

§

fn into_owned(self) -> T

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
§

impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

§

fn upcast(self, interner: I) -> U

§

impl<I, T> UpcastFrom<I, T> for T

§

fn upcast_from(from: T, _tcx: I) -> T

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more