Most of the DeconstructedPat Debug impl is reusable

This commit is contained in:
Nadrieril 2024-01-24 20:04:33 +01:00
parent cd6d8f2a04
commit bdab213993
3 changed files with 86 additions and 102 deletions

View file

@ -108,8 +108,12 @@ pub trait TypeCx: Sized + fmt::Debug {
/// This must follow the invariants of `ConstructorSet`
fn ctors_for_ty(&self, ty: &Self::Ty) -> Result<ConstructorSet<Self>, Self::Error>;
/// Best-effort `Debug` implementation.
fn debug_pat(f: &mut fmt::Formatter<'_>, pat: &DeconstructedPat<'_, Self>) -> fmt::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`.
fn write_variant_name(
f: &mut fmt::Formatter<'_>,
pat: &crate::pat::DeconstructedPat<'_, Self>,
) -> fmt::Result;
/// Raise a bug.
fn bug(&self, fmt: fmt::Arguments<'_>) -> !;