[gcc/devel/rust/master] gccrs: remove proxy class to use virtual method to get impl_item name

Thomas Schwinge tschwinge@gcc.gnu.org
Mon Mar 20 07:24:18 GMT 2023


https://gcc.gnu.org/g:7334fb00e9cf2c8adfe2a197087652f5af451614

commit 7334fb00e9cf2c8adfe2a197087652f5af451614
Author: Philip Herron <herron.philip@googlemail.com>
Date:   Wed Mar 15 16:50:03 2023 +0000

    gccrs: remove proxy class to use virtual method to get impl_item name
    
    gcc/rust/ChangeLog:
    
            * typecheck/rust-hir-inherent-impl-overlap.h (class ImplItemToName): remove
    
    Signed-off-by: Philip Herron <herron.philip@googlemail.com>

Diff:
---
 .../typecheck/rust-hir-inherent-impl-overlap.h     | 42 +---------------------
 1 file changed, 1 insertion(+), 41 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h b/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h
index 3c486077aa5..0eeaac666d5 100644
--- a/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h
+++ b/gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h
@@ -25,43 +25,6 @@
 namespace Rust {
 namespace Resolver {
 
-class ImplItemToName : private TypeCheckBase, private HIR::HIRImplVisitor
-{
-public:
-  static bool resolve (HIR::ImplItem *item, std::string &name_result)
-  {
-    ImplItemToName resolver (name_result);
-    item->accept_vis (resolver);
-    return resolver.ok;
-  }
-
-  void visit (HIR::TypeAlias &alias) override
-  {
-    ok = true;
-    result.assign (alias.get_new_type_name ());
-  }
-
-  void visit (HIR::Function &function) override
-  {
-    ok = true;
-    result.assign (function.get_function_name ());
-  }
-
-  void visit (HIR::ConstantItem &constant) override
-  {
-    ok = true;
-    result.assign (constant.get_identifier ());
-  }
-
-private:
-  ImplItemToName (std::string &result)
-    : TypeCheckBase (), ok (false), result (result)
-  {}
-
-  bool ok;
-  std::string &result;
-};
-
 class OverlappingImplItemPass : public TypeCheckBase
 {
 public:
@@ -97,10 +60,7 @@ public:
     if (!ok)
       return;
 
-    std::string impl_item_name;
-    ok = ImplItemToName::resolve (impl_item, impl_item_name);
-    rust_assert (ok);
-
+    std::string impl_item_name = impl_item->get_impl_item_name ();
     std::pair<HIR::ImplItem *, std::string> elem (impl_item, impl_item_name);
     impl_mappings[impl_type].insert (std::move (elem));
   }


More information about the Gcc-cvs mailing list