]> gcc.gnu.org Git - gcc.git/commitdiff
gccrs: Implement Dump:visit() function for QualifiedPathInType argument.
authorZheyuan Chen <sephirotheca17@gmail.com>
Thu, 13 Apr 2023 12:57:31 +0000 (05:57 -0700)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:34:10 +0000 (18:34 +0100)
gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc: fix bad formatting for associated type.

Signed-off-by: Zheyuan Chen <sephirotheca17@gmail.com>
gcc/rust/ast/rust-ast-dump.cc

index ce934a1ed7aeb0b2be1e57d798ea811862838d33..f8c4f50c27d72c37867c2b8c9bc20935b9af8dcf 100644 (file)
@@ -488,8 +488,20 @@ Dump::visit (QualifiedPathInExpression &path)
 }
 
 void
-Dump::visit (QualifiedPathInType &)
-{}
+Dump::visit (QualifiedPathInType &path)
+{
+  auto qualified_path_type = path.get_qualified_path_type ();
+  stream << "<";
+  visit (qualified_path_type.get_type ());
+  if (qualified_path_type.has_as_clause ())
+    {
+      stream << " as ";
+      visit (qualified_path_type.get_as_type_path ());
+    }
+  stream << ">::";
+  visit (path.get_associated_segment ());
+  visit_items_joined_by_separator (path.get_segments (), "::");
+}
 
 // rust-expr.h
 void
@@ -1153,7 +1165,6 @@ Dump::visit (TypeAlias &type_alias)
   // Visibility? type IDENTIFIER GenericParams? WhereClause? = Type;
 
   // Note: Associated types are handled by `AST::TraitItemType`.
-
   if (type_alias.has_visibility ())
     visit (type_alias.get_visibility ());
   stream << "type " << type_alias.get_new_type_name ();
@@ -1163,6 +1174,7 @@ Dump::visit (TypeAlias &type_alias)
     visit (type_alias.get_where_clause ());
   stream << " = ";
   visit (type_alias.get_type_aliased ());
+  stream << ";\n";
 }
 
 void
This page took 0.196263 seconds and 5 git commands to generate.