From bdab21399372bee9127b5e6641c8a54034005138 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 24 Jan 2024 20:04:33 +0100 Subject: Most of the `DeconstructedPat` `Debug` impl is reusable --- compiler/rustc_pattern_analysis/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'compiler/rustc_pattern_analysis/src/lib.rs') diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs index 4fd01b5e638..51784903178 100644 --- a/compiler/rustc_pattern_analysis/src/lib.rs +++ b/compiler/rustc_pattern_analysis/src/lib.rs @@ -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, 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<'_>) -> !; -- cgit 1.4.1-3-g733a5