From 2ef9814c6e27a2860951151e09f2c6230379970f Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Wed, 11 Oct 2023 15:02:38 -0400 Subject: [PATCH] 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 --- 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 c8f64402c2f1..abb0227426a1 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);