about summary refs log tree commit diff
path: root/compiler/rustc_hir_pretty/src
diff options
context:
space:
mode:
authorDaniPopes <57450786+DaniPopes@users.noreply.github.com>2023-10-25 01:05:26 +0200
committerDaniPopes <57450786+DaniPopes@users.noreply.github.com>2023-10-25 17:36:04 +0200
commit2c1dbed4aa049d5bb5b7d83d3c856519ee27a1dc (patch)
tree834f52639839ab441b61076a3b208b3bf580b509 /compiler/rustc_hir_pretty/src
parentb66fe58f68d84cf422ff50c362ac5ad245cd9ce7 (diff)
downloadrust-2c1dbed4aa049d5bb5b7d83d3c856519ee27a1dc.tar.gz
rust-2c1dbed4aa049d5bb5b7d83d3c856519ee27a1dc.zip
Print variadic argument pattern in HIR pretty printer
Diffstat (limited to 'compiler/rustc_hir_pretty/src')
-rw-r--r--compiler/rustc_hir_pretty/src/lib.rs19
1 files changed, 12 insertions, 7 deletions
diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs
index ab6ab391484..1ce6bb6ca15 100644
--- a/compiler/rustc_hir_pretty/src/lib.rs
+++ b/compiler/rustc_hir_pretty/src/lib.rs
@@ -502,13 +502,13 @@ impl<'a> State<'a> {
                 self.word(";");
                 self.end(); // end the outer cbox
             }
-            hir::ItemKind::Fn(ref sig, param_names, body) => {
+            hir::ItemKind::Fn(ref sig, generics, body) => {
                 self.head("");
                 self.print_fn(
                     sig.decl,
                     sig.header,
                     Some(item.ident.name),
-                    param_names,
+                    generics,
                     &[],
                     Some(body),
                 );
@@ -1948,11 +1948,10 @@ impl<'a> State<'a> {
         self.print_generic_params(generics.params);
 
         self.popen();
-        let mut i = 0;
         // Make sure we aren't supplied *both* `arg_names` and `body_id`.
         assert!(arg_names.is_empty() || body_id.is_none());
-        self.commasep(Inconsistent, decl.inputs, |s, ty| {
-            s.ibox(INDENT_UNIT);
+        let mut i = 0;
+        let mut print_arg = |s: &mut Self| {
             if let Some(arg_name) = arg_names.get(i) {
                 s.word(arg_name.to_string());
                 s.word(":");
@@ -1963,11 +1962,17 @@ impl<'a> State<'a> {
                 s.space();
             }
             i += 1;
+        };
+        self.commasep(Inconsistent, decl.inputs, |s, ty| {
+            s.ibox(INDENT_UNIT);
+            print_arg(s);
             s.print_type(ty);
-            s.end()
+            s.end();
         });
         if decl.c_variadic {
-            self.word(", ...");
+            self.word(", ");
+            print_arg(self);
+            self.word("...");
         }
         self.pclose();