pub trait TypeCx: Sized + Debug {
    type Ty: Copy + Clone + Debug;
    type Error: Debug;
    type VariantIdx: Clone + Idx;
    type StrLit: Clone + PartialEq + Debug;
    type ArmData: Copy + Clone + Debug;
    type PatData: Clone;

    // Required methods
    fn is_exhaustive_patterns_feature_on(&self) -> bool;
    fn ctor_arity(&self, ctor: &Constructor<Self>, ty: Self::Ty) -> usize;
    fn ctor_sub_tys(
        &self,
        ctor: &Constructor<Self>,
        ty: Self::Ty
    ) -> &[Self::Ty];
    fn ctors_for_ty(
        &self,
        ty: Self::Ty
    ) -> Result<ConstructorSet<Self>, Self::Error>;
    fn debug_pat(
        f: &mut Formatter<'_>,
        pat: &DeconstructedPat<'_, Self>
    ) -> Result;
    fn bug(&self, fmt: Arguments<'_>) -> !;
}
Expand description

Context that provides type information about constructors.

Most of the crate is parameterized on a type that implements this trait.

Required Associated Types§

source

type Ty: Copy + Clone + Debug

The type of a pattern.

source

type Error: Debug

Errors that can abort analysis.

source

type VariantIdx: Clone + Idx

The index of an enum variant.

source

type StrLit: Clone + PartialEq + Debug

A string literal

source

type ArmData: Copy + Clone + Debug

Extra data to store in a match arm.

source

type PatData: Clone

Extra data to store in a pattern.

Required Methods§

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) -> &[Self::Ty]

The types of the fields for this constructor. The result must have a length of ctor_arity().

source

fn ctors_for_ty( &self, ty: Self::Ty ) -> Result<ConstructorSet<Self>, Self::Error>

The set of all the constructors for ty.

This must follow the invariants of ConstructorSet

source

fn debug_pat(f: &mut Formatter<'_>, pat: &DeconstructedPat<'_, Self>) -> Result

Best-effort Debug implementation.

source

fn bug(&self, fmt: Arguments<'_>) -> !

Raise a bug.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'p, 'tcx> TypeCx for RustcMatchCheckCtxt<'p, 'tcx>

§

type Ty = RevealedTy<'tcx>

§

type Error = ErrorGuaranteed

§

type VariantIdx = VariantIdx

§

type StrLit = Const<'tcx>

§

type ArmData = HirId

§

type PatData = &'p Pat<'tcx>