diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2024-08-03 21:20:22 +1000 | 
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2024-08-11 20:25:03 +1000 | 
| commit | fc55129774c8209d46d89b8a27b13fb7d8ce2b44 (patch) | |
| tree | 445a0fb971d8f0838d7677d0a3e593b3ea2e3fe2 /compiler/rustc_pattern_analysis/src/rustc/print.rs | |
| parent | bfe88a3bd0d0af92405655495a40aefbbed29b23 (diff) | |
| download | rust-fc55129774c8209d46d89b8a27b13fb7d8ce2b44.tar.gz rust-fc55129774c8209d46d89b8a27b13fb7d8ce2b44.zip  | |
Remove `print::Pat` entirely, replacing it with `String`
Diffstat (limited to 'compiler/rustc_pattern_analysis/src/rustc/print.rs')
| -rw-r--r-- | compiler/rustc_pattern_analysis/src/rustc/print.rs | 34 | 
1 files changed, 7 insertions, 27 deletions
diff --git a/compiler/rustc_pattern_analysis/src/rustc/print.rs b/compiler/rustc_pattern_analysis/src/rustc/print.rs index b2ecfa2ae28..17e389df17e 100644 --- a/compiler/rustc_pattern_analysis/src/rustc/print.rs +++ b/compiler/rustc_pattern_analysis/src/rustc/print.rs @@ -17,32 +17,12 @@ use rustc_span::sym; use rustc_target::abi::{FieldIdx, VariantIdx}; #[derive(Clone, Debug)] -pub(crate) struct FieldPat<'tcx> { +pub(crate) struct FieldPat { pub(crate) field: FieldIdx, - pub(crate) pattern: Box<Pat<'tcx>>, + pub(crate) pattern: String, pub(crate) is_wildcard: bool, } -#[derive(Clone, Debug)] -pub(crate) struct Pat<'tcx> { - #[allow(dead_code)] - pub(crate) ty: Ty<'tcx>, - pub(crate) kind: PatKind, -} - -#[derive(Clone, Debug)] -pub(crate) enum PatKind { - Print(String), -} - -impl<'tcx> fmt::Display for Pat<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.kind { - PatKind::Print(ref string) => write!(f, "{string}"), - } - } -} - /// Returns a closure that will return `""` when called the first time, /// and then return `", "` when called any subsequent times. /// Useful for printing comma-separated lists. @@ -69,7 +49,7 @@ pub(crate) fn write_struct_like<'tcx>( tcx: TyCtxt<'_>, ty: Ty<'tcx>, enum_info: &EnumInfo<'tcx>, - subpatterns: &[FieldPat<'tcx>], + subpatterns: &[FieldPat], ) -> fmt::Result { let variant_and_name = match *enum_info { EnumInfo::Enum { adt_def, variant_index } => { @@ -148,7 +128,7 @@ pub(crate) fn write_struct_like<'tcx>( pub(crate) fn write_ref_like<'tcx>( f: &mut impl fmt::Write, ty: Ty<'tcx>, - subpattern: &Pat<'tcx>, + subpattern: &str, ) -> fmt::Result { match ty.kind() { ty::Ref(_, _, mutbl) => { @@ -159,11 +139,11 @@ pub(crate) fn write_ref_like<'tcx>( write!(f, "{subpattern}") } -pub(crate) fn write_slice_like<'tcx>( +pub(crate) fn write_slice_like( f: &mut impl fmt::Write, - prefix: &[Box<Pat<'tcx>>], + prefix: &[String], has_dot_dot: bool, - suffix: &[Box<Pat<'tcx>>], + suffix: &[String], ) -> fmt::Result { let mut start_or_comma = start_or_comma(); write!(f, "[")?;  | 
