Struct rustc_pattern_analysis::cx::MatchCheckCtxt
source · 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: DefIdThe 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: HirIdLint level at the match.
whole_match_span: Option<Span>The span of the whole match, if applicable.
scrut_span: SpanSpan of the scrutinee.
refutable: boolOnly produce NON_EXHAUSTIVE_OMITTED_PATTERNS lint on refutable patterns.
known_valid_scrutinee: boolWhether 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>
impl<'p, 'tcx> MatchCheckCtxt<'p, 'tcx>
pub(crate) fn is_uninhabited(&self, ty: Ty<'tcx>) -> bool
sourcepub fn is_foreign_non_exhaustive_enum(&self, ty: Ty<'tcx>) -> bool
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].
pub(crate) fn alloc_wildcard_slice( &self, tys: impl IntoIterator<Item = Ty<'tcx>> ) -> &'p [DeconstructedPat<'p, 'tcx>]
pub(crate) fn variant_index_for_adt( ctor: &Constructor<'tcx>, adt: AdtDef<'tcx> ) -> VariantIdx
sourcepub(crate) fn ctor_wildcard_fields(
&self,
ctor: &Constructor<'tcx>,
ty: Ty<'tcx>
) -> &'p [DeconstructedPat<'p, 'tcx>]
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().
sourcepub(crate) fn ctor_arity(&self, ctor: &Constructor<'tcx>, ty: Ty<'tcx>) -> usize
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.
sourcepub fn ctors_for_ty(&self, ty: Ty<'tcx>) -> ConstructorSet
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.
pub(crate) fn lower_pat_range_bdy( &self, bdy: PatRangeBoundary<'tcx>, ty: Ty<'tcx> ) -> MaybeInfiniteInt
sourcepub fn lower_pat(&self, pat: &Pat<'tcx>) -> DeconstructedPat<'p, 'tcx>
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.
sourcepub(crate) fn hoist_pat_range_bdy(
&self,
miint: MaybeInfiniteInt,
ty: Ty<'tcx>
) -> PatRangeBoundary<'tcx>
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.
sourcepub fn is_range_beyond_boundaries(&self, range: &IntRange, ty: Ty<'tcx>) -> bool
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).
sourcepub(crate) fn hoist_pat_range(
&self,
range: &IntRange,
ty: Ty<'tcx>
) -> Pat<'tcx>
pub(crate) fn hoist_pat_range( &self, range: &IntRange, ty: Ty<'tcx> ) -> Pat<'tcx>
Convert back to a thir::Pat for diagnostic purposes.
sourcepub fn hoist_witness_pat(&self, pat: &WitnessPat<'tcx>) -> Pat<'tcx>
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.
sourcepub(crate) fn debug_pat(
f: &mut Formatter<'_>,
pat: &DeconstructedPat<'p, 'tcx>
) -> Result
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> 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
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