Skip to content

Commit

Permalink
Make lowering of AssociatedItem instances polymorphic
Browse files Browse the repository at this point in the history
gcc/rust/ChangeLog:

	* hir/rust-ast-lower-implitem.h
	(ASTLoweringImplItem::translate): Take AssociatedItem as parameter.
	(ASTLoweringTraitItem::translate): Likewise.

Signed-off-by: Owen Avery <[email protected]>
  • Loading branch information
powerboat9 authored and CohenArthur committed Oct 20, 2023
1 parent 9a53cb5 commit 2ef9814
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions gcc/rust/hir/rust-ast-lower-implitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 2ef9814

Please sign in to comment.