public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] refactor away from helper utility methods and just use the constructor directly
Date: Wed, 29 Jun 2022 10:27:35 +0000 (GMT)	[thread overview]
Message-ID: <20220629102735.79B493842AD6@sourceware.org> (raw)

https://gcc.gnu.org/g:da2dda70637ecd42a9ba3fba976a5f280e880852

commit da2dda70637ecd42a9ba3fba976a5f280e880852
Author: Philip Herron <philip.herron@embecosm.com>
Date:   Mon Jun 27 17:48:55 2022 +0100

    refactor away from helper utility methods and just use the constructor directly

Diff:
---
 gcc/rust/resolve/rust-ast-resolve-implitem.h | 22 ++++++---
 gcc/rust/resolve/rust-ast-resolve-item.cc    | 22 ++++++---
 gcc/rust/resolve/rust-ast-resolve-stmt.h     |  6 ++-
 gcc/rust/resolve/rust-ast-resolve-toplevel.h |  6 ++-
 gcc/rust/resolve/rust-ast-resolve-type.h     | 70 ----------------------------
 5 files changed, 38 insertions(+), 88 deletions(-)

diff --git a/gcc/rust/resolve/rust-ast-resolve-implitem.h b/gcc/rust/resolve/rust-ast-resolve-implitem.h
index c0cb3a7a311..192ecaf42e6 100644
--- a/gcc/rust/resolve/rust-ast-resolve-implitem.h
+++ b/gcc/rust/resolve/rust-ast-resolve-implitem.h
@@ -66,7 +66,8 @@ public:
 
   void visit (AST::ConstantItem &constant) override
   {
-    auto decl = ResolveConstantItemToCanonicalPath::resolve (constant);
+    auto decl = CanonicalPath::new_seg (constant.get_node_id (),
+					constant.get_identifier ());
     auto path = prefix.append (decl);
 
     resolver->get_name_scope ().insert (
@@ -80,7 +81,8 @@ public:
 
   void visit (AST::Function &function) override
   {
-    auto decl = ResolveFunctionItemToCanonicalPath::resolve (function);
+    auto decl = CanonicalPath::new_seg (function.get_node_id (),
+					function.get_function_name ());
     auto path = prefix.append (decl);
 
     resolver->get_name_scope ().insert (
@@ -94,7 +96,8 @@ public:
 
   void visit (AST::Method &method) override
   {
-    auto decl = ResolveMethodItemToCanonicalPath::resolve (method);
+    auto decl = CanonicalPath::new_seg (method.get_node_id (),
+					method.get_method_name ());
     auto path = prefix.append (decl);
 
     resolver->get_name_scope ().insert (
@@ -130,7 +133,9 @@ public:
 
   void visit (AST::TraitItemFunc &function) override
   {
-    auto decl = ResolveTraitItemFunctionToCanonicalPath::resolve (function);
+    auto decl = CanonicalPath::new_seg (
+      function.get_node_id (),
+      function.get_trait_function_decl ().get_identifier ());
     auto path = prefix.append (decl);
     auto cpath = canonical_prefix.append (decl);
 
@@ -148,7 +153,8 @@ public:
 
   void visit (AST::TraitItemMethod &method) override
   {
-    auto decl = ResolveTraitItemMethodToCanonicalPath::resolve (method);
+    auto decl = CanonicalPath::new_seg (
+      method.get_node_id (), method.get_trait_method_decl ().get_identifier ());
     auto path = prefix.append (decl);
     auto cpath = canonical_prefix.append (decl);
 
@@ -166,7 +172,8 @@ public:
 
   void visit (AST::TraitItemConst &constant) override
   {
-    auto decl = ResolveTraitItemConstToCanonicalPath::resolve (constant);
+    auto decl = CanonicalPath::new_seg (constant.get_node_id (),
+					constant.get_identifier ());
     auto path = prefix.append (decl);
     auto cpath = canonical_prefix.append (decl);
 
@@ -184,7 +191,8 @@ public:
 
   void visit (AST::TraitItemType &type) override
   {
-    auto decl = ResolveTraitItemTypeToCanonicalPath::resolve (type);
+    auto decl
+      = CanonicalPath::new_seg (type.get_node_id (), type.get_identifier ());
     auto path = prefix.append (decl);
     auto cpath = canonical_prefix.append (decl);
 
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc
index 7b0c31b2edc..0c9536ff38d 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-item.cc
@@ -42,7 +42,8 @@ ResolveTraitItems::go (AST::TraitItem *item, const CanonicalPath &prefix,
 void
 ResolveTraitItems::visit (AST::TraitItemType &type)
 {
-  auto decl = ResolveTraitItemTypeToCanonicalPath::resolve (type);
+  auto decl
+    = CanonicalPath::new_seg (type.get_node_id (), type.get_identifier ());
   auto path = prefix.append (decl);
   auto cpath = canonical_prefix.append (decl);
   mappings->insert_canonical_path (mappings->get_current_crate (),
@@ -55,7 +56,8 @@ ResolveTraitItems::visit (AST::TraitItemType &type)
 void
 ResolveTraitItems::visit (AST::TraitItemFunc &func)
 {
-  auto decl = ResolveTraitItemFunctionToCanonicalPath::resolve (func);
+  auto decl = CanonicalPath::new_seg (
+    func.get_node_id (), func.get_trait_function_decl ().get_identifier ());
   auto path = prefix.append (decl);
   auto cpath = canonical_prefix.append (decl);
   mappings->insert_canonical_path (mappings->get_current_crate (),
@@ -102,7 +104,9 @@ ResolveTraitItems::visit (AST::TraitItemFunc &func)
 void
 ResolveTraitItems::visit (AST::TraitItemMethod &func)
 {
-  auto decl = ResolveTraitItemMethodToCanonicalPath::resolve (func);
+  auto decl
+    = CanonicalPath::new_seg (func.get_node_id (),
+			      func.get_trait_method_decl ().get_identifier ());
   auto path = prefix.append (decl);
   auto cpath = canonical_prefix.append (decl);
   mappings->insert_canonical_path (mappings->get_current_crate (),
@@ -166,7 +170,8 @@ ResolveTraitItems::visit (AST::TraitItemMethod &func)
 void
 ResolveTraitItems::visit (AST::TraitItemConst &constant)
 {
-  auto decl = ResolveTraitItemConstToCanonicalPath::resolve (constant);
+  auto decl = CanonicalPath::new_seg (constant.get_node_id (),
+				      constant.get_identifier ());
   auto path = prefix.append (decl);
   auto cpath = canonical_prefix.append (decl);
   mappings->insert_canonical_path (mappings->get_current_crate (),
@@ -486,7 +491,8 @@ ResolveItem::visit (AST::StaticItem &var)
 void
 ResolveItem::visit (AST::ConstantItem &constant)
 {
-  auto decl = ResolveConstantItemToCanonicalPath::resolve (constant);
+  auto decl = CanonicalPath::new_seg (constant.get_node_id (),
+				      constant.get_identifier ());
   auto path = prefix.append (decl);
   auto cpath = canonical_prefix.append (decl);
   mappings->insert_canonical_path (mappings->get_current_crate (),
@@ -501,7 +507,8 @@ ResolveItem::visit (AST::ConstantItem &constant)
 void
 ResolveItem::visit (AST::Function &function)
 {
-  auto decl = ResolveFunctionItemToCanonicalPath::resolve (function);
+  auto decl = CanonicalPath::new_seg (function.get_node_id (),
+				      function.get_function_name ());
   auto path = prefix.append (decl);
   auto cpath = canonical_prefix.append (decl);
 
@@ -638,7 +645,8 @@ ResolveItem::visit (AST::InherentImpl &impl_block)
 void
 ResolveItem::visit (AST::Method &method)
 {
-  auto decl = ResolveMethodItemToCanonicalPath::resolve (method);
+  auto decl
+    = CanonicalPath::new_seg (method.get_node_id (), method.get_method_name ());
   auto path = prefix.append (decl);
   auto cpath = canonical_prefix.append (decl);
   mappings->insert_canonical_path (mappings->get_current_crate (),
diff --git a/gcc/rust/resolve/rust-ast-resolve-stmt.h b/gcc/rust/resolve/rust-ast-resolve-stmt.h
index 95c25a5ad77..1d2ecd35207 100644
--- a/gcc/rust/resolve/rust-ast-resolve-stmt.h
+++ b/gcc/rust/resolve/rust-ast-resolve-stmt.h
@@ -56,7 +56,8 @@ public:
 
   void visit (AST::ConstantItem &constant) override
   {
-    auto decl = ResolveConstantItemToCanonicalPath::resolve (constant);
+    auto decl = CanonicalPath::new_seg (constant.get_node_id (),
+					constant.get_identifier ());
     auto path = decl; // this ensures we have the correct relative resolution
     auto cpath = canonical_prefix.append (decl);
     mappings->insert_canonical_path (mappings->get_current_crate (),
@@ -330,7 +331,8 @@ public:
 
   void visit (AST::Function &function) override
   {
-    auto decl = ResolveFunctionItemToCanonicalPath::resolve (function);
+    auto decl = CanonicalPath::new_seg (function.get_node_id (),
+					function.get_function_name ());
     auto path = decl; // this ensures we have the correct relative resolution
     auto cpath = canonical_prefix.append (decl);
     mappings->insert_canonical_path (mappings->get_current_crate (),
diff --git a/gcc/rust/resolve/rust-ast-resolve-toplevel.h b/gcc/rust/resolve/rust-ast-resolve-toplevel.h
index c495786f6f8..aed8565c8d5 100644
--- a/gcc/rust/resolve/rust-ast-resolve-toplevel.h
+++ b/gcc/rust/resolve/rust-ast-resolve-toplevel.h
@@ -283,7 +283,8 @@ public:
 
   void visit (AST::ConstantItem &constant) override
   {
-    auto decl = ResolveConstantItemToCanonicalPath::resolve (constant);
+    auto decl = CanonicalPath::new_seg (constant.get_node_id (),
+					constant.get_identifier ());
     auto path = prefix.append (decl);
     auto cpath = canonical_prefix.append (decl);
 
@@ -303,7 +304,8 @@ public:
 
   void visit (AST::Function &function) override
   {
-    auto decl = ResolveFunctionItemToCanonicalPath::resolve (function);
+    auto decl = CanonicalPath::new_seg (function.get_node_id (),
+					function.get_function_name ());
     auto path = prefix.append (decl);
     auto cpath = canonical_prefix.append (decl);
 
diff --git a/gcc/rust/resolve/rust-ast-resolve-type.h b/gcc/rust/resolve/rust-ast-resolve-type.h
index aab6a1afd7d..b8ad6d1756a 100644
--- a/gcc/rust/resolve/rust-ast-resolve-type.h
+++ b/gcc/rust/resolve/rust-ast-resolve-type.h
@@ -25,76 +25,6 @@
 namespace Rust {
 namespace Resolver {
 
-class ResolveConstantItemToCanonicalPath
-{
-public:
-  static CanonicalPath resolve (AST::ConstantItem &constant)
-  {
-    return CanonicalPath::new_seg (constant.get_node_id (),
-				   constant.get_identifier ());
-  }
-};
-
-class ResolveFunctionItemToCanonicalPath
-{
-public:
-  static CanonicalPath resolve (AST::Function &function)
-  {
-    return CanonicalPath::new_seg (function.get_node_id (),
-				   function.get_function_name ());
-  }
-};
-
-class ResolveMethodItemToCanonicalPath
-{
-public:
-  static CanonicalPath resolve (AST::Method &method)
-  {
-    return CanonicalPath::new_seg (method.get_node_id (),
-				   method.get_method_name ());
-  }
-};
-
-class ResolveTraitItemFunctionToCanonicalPath
-{
-public:
-  static CanonicalPath resolve (AST::TraitItemFunc &function)
-  {
-    return CanonicalPath::new_seg (
-      function.get_node_id (),
-      function.get_trait_function_decl ().get_identifier ());
-  }
-};
-
-class ResolveTraitItemMethodToCanonicalPath
-{
-public:
-  static CanonicalPath resolve (AST::TraitItemMethod &method)
-  {
-    return CanonicalPath::new_seg (
-      method.get_node_id (), method.get_trait_method_decl ().get_identifier ());
-  }
-};
-
-class ResolveTraitItemConstToCanonicalPath
-{
-public:
-  static CanonicalPath resolve (AST::TraitItemConst &constant)
-  {
-    return CanonicalPath::new_seg (constant.get_node_id (),
-				   constant.get_identifier ());
-  }
-};
-
-class ResolveTraitItemTypeToCanonicalPath
-{
-public:
-  static CanonicalPath resolve (AST::TraitItemType &type)
-  {
-    return CanonicalPath::new_seg (type.get_node_id (), type.get_identifier ());
-  }
-};
-
 class ResolveTypeToCanonicalPath : public ResolverBase
 {
 protected:


                 reply	other threads:[~2022-06-29 10:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220629102735.79B493842AD6@sourceware.org \
    --to=tschwinge@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).