[gcc r14-8065] gccrs: Make lowering of AssociatedItem instances polymorphic

Arthur Cohen cohenarthur@gcc.gnu.org
Tue Jan 16 18:15:35 GMT 2024


https://gcc.gnu.org/g:124bfaf4323f627bd7721401c3a86f369f45a1b2

commit r14-8065-g124bfaf4323f627bd7721401c3a86f369f45a1b2
Author: Owen Avery <powerboat9.gamer@gmail.com>
Date:   Wed Oct 11 15:02:38 2023 -0400

    gccrs: Make lowering of AssociatedItem instances polymorphic
    
    gcc/rust/ChangeLog:
    
            * hir/rust-ast-lower-implitem.h
            (ASTLoweringImplItem::translate): Take AssociatedItem as parameter.
            (ASTLoweringTraitItem::translate): Likewise.
    
    Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>

Diff:
---
 gcc/rust/hir/rust-ast-lower-implitem.h | 28 ++--------------------------
 1 file changed, 2 insertions(+), 26 deletions(-)

diff --git a/gcc/rust/hir/rust-ast-lower-implitem.h b/gcc/rust/hir/rust-ast-lower-implitem.h
index 9aef2cb9306..91c94708964 100644
--- a/gcc/rust/hir/rust-ast-lower-implitem.h
+++ b/gcc/rust/hir/rust-ast-lower-implitem.h
@@ -32,31 +32,7 @@ class ASTLowerImplItem : public ASTLoweringBase
   using Rust::HIR::ASTLoweringBase::visit;
 
 public:
-  static HIR::ImplItem *translate (AST::InherentImplItem *item,
-				   HirId parent_impl_id)
-  {
-    ASTLowerImplItem resolver;
-    item->accept_vis (resolver);
-
-    if (resolver.translated != nullptr)
-      {
-	rust_assert (resolver.item_cast != nullptr);
-
-	auto id = resolver.translated->get_impl_mappings ().get_hirid ();
-	auto defid = resolver.translated->get_impl_mappings ().get_defid ();
-	auto locus = resolver.translated->get_locus ();
-
-	resolver.handle_outer_attributes (*resolver.item_cast);
-	resolver.mappings->insert_hir_implitem (parent_impl_id,
-						resolver.translated);
-	resolver.mappings->insert_location (id, locus);
-	resolver.mappings->insert_defid_mapping (defid, resolver.item_cast);
-      }
-
-    return resolver.translated;
-  }
-
-  static HIR::ImplItem *translate (AST::TraitImplItem *item,
+  static HIR::ImplItem *translate (AST::AssociatedItem *item,
 				   HirId parent_impl_id)
   {
     ASTLowerImplItem resolver;
@@ -312,7 +288,7 @@ class ASTLowerTraitItem : public ASTLoweringBase
   using Rust::HIR::ASTLoweringBase::visit;
 
 public:
-  static HIR::TraitItem *translate (AST::TraitItem *item)
+  static HIR::TraitItem *translate (AST::AssociatedItem *item)
   {
     ASTLowerTraitItem resolver;
     item->accept_vis (resolver);


More information about the Gcc-cvs mailing list