gccrs: ast: Dump no comma after self in fn params if it is the last one
authorJakub Dupak <dev@jakubdupak.com>
Wed, 16 Nov 2022 13:16:51 +0000 (14:16 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 21 Feb 2023 11:36:50 +0000 (12:36 +0100)
gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Fix dumping of fn params.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
gcc/rust/ast/rust-ast-dump.cc

index 9ec847c..131e23e 100644 (file)
@@ -1077,8 +1077,12 @@ Dump::visit (Method &method)
   visit (method.get_visibility ());
   stream << "fn " << method.get_method_name () << '(';
 
-  stream << method.get_self_param ().as_string () << ", ";
-  visit_items_joined_by_separator (method.get_function_params (), ", ");
+  stream << method.get_self_param ().as_string ();
+  if (!method.get_function_params ().empty ())
+    {
+      stream << ", ";
+      visit_items_joined_by_separator (method.get_function_params (), ", ");
+    }
 
   stream << ") ";
 
@@ -1343,9 +1347,13 @@ Dump::visit (TraitItemMethod &item)
   // emit_visibility (method.get_visibility ());
   stream << "fn " << method.get_identifier () << '(';
 
-  stream << method.get_self_param ().as_string () << ", ";
+  stream << method.get_self_param ().as_string ();
 
-  visit_items_joined_by_separator (method.get_function_params (), ", ");
+  if (!method.get_function_params ().empty ())
+    {
+      stream << ", ";
+      visit_items_joined_by_separator (method.get_function_params (), ", ");
+    }
 
   stream << ") ";