]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: remove proxy class to use virtual method to get impl_item name
authorPhilip Herron <herron.philip@googlemail.com>
Wed, 15 Mar 2023 16:50:03 +0000 (16:50 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:21:12 +0000 (18:21 +0100)
gcc/rust/ChangeLog:

* typecheck/rust-hir-inherent-impl-overlap.h (class ImplItemToName): remove

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/typecheck/rust-hir-inherent-impl-overlap.h

index c6db896bb4fef40d3be317785da43b27e1851a9e..6ab5dc020077098ce39bec88c5e078dc46069ff2 100644 (file)
 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));
   }