summary refs log tree commit diff
path: root/compiler/rustc_ast_pretty/src
diff options
context:
space:
mode:
authorOli Scherer <github333195615777966@oli-obk.de>2025-02-06 13:48:12 +0000
committerOli Scherer <github333195615777966@oli-obk.de>2025-02-11 08:51:05 +0000
commit6d7ce4e893003cc652428ec02eb752bba63645e2 (patch)
treecaf8b8ce21c274ebb92c49fa29b92c7ccd0a6f49 /compiler/rustc_ast_pretty/src
parentc182ce9cbc8c29ebc1b4559d027df545e6cdd287 (diff)
downloadrust-6d7ce4e893003cc652428ec02eb752bba63645e2.tar.gz
rust-6d7ce4e893003cc652428ec02eb752bba63645e2.zip
Add a TyPat in the AST to reuse the generic arg lowering logic
Diffstat (limited to 'compiler/rustc_ast_pretty/src')
-rw-r--r--compiler/rustc_ast_pretty/src/pprust/state.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs
index eeec24e5ea4..0bf5de3ef89 100644
--- a/compiler/rustc_ast_pretty/src/pprust/state.rs
+++ b/compiler/rustc_ast_pretty/src/pprust/state.rs
@@ -1148,6 +1148,28 @@ impl<'a> State<'a> {
         }
     }
 
+    pub fn print_ty_pat(&mut self, pat: &ast::TyPat) {
+        match &pat.kind {
+            rustc_ast::TyPatKind::Range(start, end, include_end) => {
+                if let Some(start) = start {
+                    self.print_expr_anon_const(start, &[]);
+                }
+                self.word("..");
+                if let Some(end) = end {
+                    if let RangeEnd::Included(_) = include_end.node {
+                        self.word("=");
+                    }
+                    self.print_expr_anon_const(end, &[]);
+                }
+            }
+            rustc_ast::TyPatKind::Err(_) => {
+                self.popen();
+                self.word("/*ERROR*/");
+                self.pclose();
+            }
+        }
+    }
+
     pub fn print_type(&mut self, ty: &ast::Ty) {
         self.maybe_print_comment(ty.span.lo());
         self.ibox(0);
@@ -1252,7 +1274,7 @@ impl<'a> State<'a> {
             ast::TyKind::Pat(ty, pat) => {
                 self.print_type(ty);
                 self.word(" is ");
-                self.print_pat(pat);
+                self.print_ty_pat(pat);
             }
         }
         self.end();