pub struct MatchCheckCtxt<'p, 'tcx> {
    pub tcx: TyCtxt<'tcx>,
    pub module: DefId,
    pub param_env: ParamEnv<'tcx>,
    pub pattern_arena: &'p TypedArena<DeconstructedPat<'p, 'tcx>>,
    pub match_lint_level: HirId,
    pub whole_match_span: Option<Span>,
    pub scrut_span: Span,
    pub refutable: bool,
    pub known_valid_scrutinee: bool,
}

Fields§

§tcx: TyCtxt<'tcx>§module: DefId

The module in which the match occurs. This is necessary for checking inhabited-ness of types because whether a type is (visibly) inhabited can depend on whether it was defined in the current module or not. E.g., struct Foo { _private: ! } cannot be seen to be empty outside its module and should not be matchable with an empty match statement.

§param_env: ParamEnv<'tcx>§pattern_arena: &'p TypedArena<DeconstructedPat<'p, 'tcx>>§match_lint_level: HirId

Lint level at the match.

§whole_match_span: Option<Span>

The span of the whole match, if applicable.

§scrut_span: Span

Span of the scrutinee.

§refutable: bool

Only produce NON_EXHAUSTIVE_OMITTED_PATTERNS lint on refutable patterns.

§known_valid_scrutinee: bool

Whether the data at the scrutinee is known to be valid. This is false if the scrutinee comes from a union field, a pointer deref, or a reference deref (pending opsem decisions).

Implementations§

source§

impl<'p, 'tcx> MatchCheckCtxt<'p, 'tcx>

source

pub(crate) fn is_uninhabited(&self, ty: Ty<'tcx>) -> bool

source

pub fn is_foreign_non_exhaustive_enum(&self, ty: Ty<'tcx>) -> bool

Returns whether the given type is an enum from another crate declared #[non_exhaustive].

source

pub(crate) fn alloc_wildcard_slice( &self, tys: impl IntoIterator<Item = Ty<'tcx>> ) -> &'p [DeconstructedPat<'p, 'tcx>]

source

pub(crate) fn list_variant_nonhidden_fields<'a>( &'a self, ty: Ty<'tcx>, variant: &'a VariantDef ) -> impl Iterator<Item = (FieldIdx, Ty<'tcx>)> + Captures<'p> + Captures<'a>

source

pub(crate) fn variant_index_for_adt( ctor: &Constructor<'tcx>, adt: AdtDef<'tcx> ) -> VariantIdx

source

pub(crate) fn ctor_wildcard_fields( &self, ctor: &Constructor<'tcx>, ty: Ty<'tcx> ) -> &'p [DeconstructedPat<'p, 'tcx>]

Creates a new list of wildcard fields for a given constructor. The result must have a length of ctor.arity().

source

pub(crate) fn ctor_arity(&self, ctor: &Constructor<'tcx>, ty: Ty<'tcx>) -> usize

The number of fields for this constructor. This must be kept in sync with Fields::wildcards.

source

pub fn ctors_for_ty(&self, ty: Ty<'tcx>) -> ConstructorSet

Creates a set that represents all the constructors of ty.

See crate::constructor for considerations of emptiness.

source

pub(crate) fn lower_pat_range_bdy( &self, bdy: PatRangeBoundary<'tcx>, ty: Ty<'tcx> ) -> MaybeInfiniteInt

source

pub fn lower_pat(&self, pat: &Pat<'tcx>) -> DeconstructedPat<'p, 'tcx>

Note: the input patterns must have been lowered through rustc_mir_build::thir::pattern::check_match::MatchVisitor::lower_pattern.

source

pub(crate) fn hoist_pat_range_bdy( &self, miint: MaybeInfiniteInt, ty: Ty<'tcx> ) -> PatRangeBoundary<'tcx>

Convert back to a thir::PatRangeBoundary for diagnostic purposes. Note: it is possible to get isize/usize::MAX+1 here, as explained in the doc for IntRange::split. This cannot be represented as a Const, so we represent it with PosInfinity.

source

pub fn is_range_beyond_boundaries(&self, range: &IntRange, ty: Ty<'tcx>) -> bool

Whether the range denotes the fictitious values before isize::MIN or after usize::MAX/isize::MAX (see doc of IntRange::split for why these exist).

source

pub(crate) fn hoist_pat_range( &self, range: &IntRange, ty: Ty<'tcx> ) -> Pat<'tcx>

Convert back to a thir::Pat for diagnostic purposes.

source

pub fn hoist_witness_pat(&self, pat: &WitnessPat<'tcx>) -> Pat<'tcx>

Convert back to a thir::Pat for diagnostic purposes. This panics for patterns that don’t appear in diagnostics, like float ranges.

source

pub(crate) fn debug_pat( f: &mut Formatter<'_>, pat: &DeconstructedPat<'p, 'tcx> ) -> Result

Best-effort Debug implementation.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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: 64 bytes