Trait rustc_pattern_analysis::TypeCx
source · 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§
sourcetype VariantIdx: Clone + Idx
type VariantIdx: Clone + Idx
The index of an enum variant.
Required Methods§
fn is_exhaustive_patterns_feature_on(&self) -> bool
sourcefn 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.
sourcefn ctor_sub_tys(&self, ctor: &Constructor<Self>, ty: Self::Ty) -> &[Self::Ty]
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().
sourcefn 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.
This must follow the invariants of ConstructorSet
sourcefn debug_pat(f: &mut Formatter<'_>, pat: &DeconstructedPat<'_, Self>) -> Result
fn debug_pat(f: &mut Formatter<'_>, pat: &DeconstructedPat<'_, Self>) -> Result
Best-effort Debug implementation.
Object Safety§
This trait is not object safe.