From: Pierre-Emmanuel Patry <pierre-emmanuel.pa...@embecosm.com>

Regular visit code can be replaced with default visit functions.

gcc/rust/ChangeLog:

        * resolve/rust-default-resolver.cc (DefaultResolver::visit): Remove
        default visit code and replace it with call to default visitor.
        * resolve/rust-default-resolver.h: Remove removed function's
        prototypes.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.pa...@embecosm.com>
---
 gcc/rust/resolve/rust-default-resolver.cc | 118 +---------------------
 gcc/rust/resolve/rust-default-resolver.h  |   8 --
 2 files changed, 3 insertions(+), 123 deletions(-)

diff --git a/gcc/rust/resolve/rust-default-resolver.cc 
b/gcc/rust/resolve/rust-default-resolver.cc
index 5ecea06bc6e..02617216799 100644
--- a/gcc/rust/resolve/rust-default-resolver.cc
+++ b/gcc/rust/resolve/rust-default-resolver.cc
@@ -170,17 +170,7 @@ DefaultResolver::visit (AST::ClosureExprInner &expr)
   if (expr.is_marked_for_strip ())
     return;
 
-  for (auto &param : expr.get_params ())
-    {
-      if (param.is_error ())
-       continue;
-
-      param.get_pattern ().accept_vis (*this);
-      if (param.has_type_given ())
-       param.get_type ().accept_vis (*this);
-    }
-
-  expr.get_definition_expr ().accept_vis (*this);
+  AST::DefaultASTVisitor::visit (expr);
 }
 
 void
@@ -189,63 +179,7 @@ DefaultResolver::visit (AST::ClosureExprInnerTyped &expr)
   if (expr.is_marked_for_strip ())
     return;
 
-  for (auto &param : expr.get_params ())
-    {
-      if (param.is_error ())
-       continue;
-
-      param.get_pattern ().accept_vis (*this);
-      if (param.has_type_given ())
-       param.get_type ().accept_vis (*this);
-    }
-
-  expr.get_definition_block ().accept_vis (*this);
-  expr.get_return_type ().accept_vis (*this);
-}
-
-void
-DefaultResolver::visit (AST::CallExpr &expr)
-{
-  expr.get_function_expr ().accept_vis (*this);
-
-  for (auto &param : expr.get_params ())
-    param->accept_vis (*this);
-}
-
-void
-DefaultResolver::visit (AST::MethodCallExpr &expr)
-{
-  expr.get_receiver_expr ().accept_vis (*this);
-
-  if (expr.get_method_name ().has_generic_args ())
-    {
-      auto &args = expr.get_method_name ().get_generic_args ();
-      for (auto &arg : args.get_generic_args ())
-       arg.accept_vis (*this);
-      for (auto &arg : args.get_binding_args ())
-       if (!arg.is_error ())
-         arg.get_type ().accept_vis (*this);
-      for (auto &arg : args.get_lifetime_args ())
-       arg.accept_vis (*this);
-    }
-
-  for (auto &param : expr.get_params ())
-    param->accept_vis (*this);
-}
-
-void
-DefaultResolver::visit (AST::IfExpr &expr)
-{
-  expr.get_condition_expr ().accept_vis (*this);
-  expr.get_if_block ().accept_vis (*this);
-}
-
-void
-DefaultResolver::visit (AST::IfExprConseqElse &expr)
-{
-  expr.get_condition_expr ().accept_vis (*this);
-  expr.get_if_block ().accept_vis (*this);
-  expr.get_else_block ().accept_vis (*this);
+  AST::DefaultASTVisitor::visit (expr);
 }
 
 void
@@ -254,53 +188,7 @@ DefaultResolver::visit (AST::MatchExpr &expr)
   if (expr.is_marked_for_strip ())
     return;
 
-  expr.get_scrutinee_expr ().accept_vis (*this);
-  for (auto &arm : expr.get_match_cases ())
-    {
-      arm.get_expr ().accept_vis (*this);
-      for (auto &pat : arm.get_arm ().get_patterns ())
-       pat->accept_vis (*this);
-      if (arm.get_arm ().has_match_arm_guard ())
-       arm.get_arm ().get_guard_expr ().accept_vis (*this);
-    }
-}
-
-void
-DefaultResolver::visit (AST::PathInExpression &expr)
-{
-  for (auto &seg : expr.get_segments ())
-    if (seg.has_generic_args ())
-      {
-       auto &args = seg.get_generic_args ();
-       for (auto &arg : args.get_generic_args ())
-         arg.accept_vis (*this);
-       for (auto &arg : args.get_binding_args ())
-         if (!arg.is_error ())
-           arg.get_type ().accept_vis (*this);
-       for (auto &arg : args.get_lifetime_args ())
-         arg.accept_vis (*this);
-      }
-}
-
-void
-DefaultResolver::visit (AST::EnumItemTuple &item)
-{
-  for (auto &field : item.get_tuple_fields ())
-    field.get_field_type ().accept_vis (*this);
-}
-
-void
-DefaultResolver::visit (AST::EnumItemStruct &item)
-{
-  for (auto &field : item.get_struct_fields ())
-    field.get_field_type ().accept_vis (*this);
-}
-
-void
-DefaultResolver::visit (AST::EnumItemDiscriminant &item)
-{
-  if (item.has_expr ())
-    item.get_expr ().accept_vis (*this);
+  AST::DefaultASTVisitor::visit (expr);
 }
 
 void
diff --git a/gcc/rust/resolve/rust-default-resolver.h 
b/gcc/rust/resolve/rust-default-resolver.h
index 553afae77c0..9fcddd15851 100644
--- a/gcc/rust/resolve/rust-default-resolver.h
+++ b/gcc/rust/resolve/rust-default-resolver.h
@@ -57,17 +57,9 @@ public:
   // Visitors that visit their expression node(s)
   void visit (AST::ClosureExprInner &) override;
   void visit (AST::ClosureExprInnerTyped &) override;
-  void visit (AST::CallExpr &) override;
-  void visit (AST::MethodCallExpr &) override;
-  void visit (AST::IfExpr &) override;
-  void visit (AST::IfExprConseqElse &) override;
   void visit (AST::MatchExpr &) override;
 
   // Leaf visitors, which do nothing by default
-  void visit (AST::PathInExpression &) override;
-  void visit (AST::EnumItemTuple &) override;
-  void visit (AST::EnumItemStruct &) override;
-  void visit (AST::EnumItemDiscriminant &) override;
   void visit (AST::ConstantItem &) override;
   void visit (AST::StaticItem &) override;
 
-- 
2.45.2

Reply via email to