Skip to content

Commit

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

	* resolve/rust-ast-resolve-implitem.h
	(ResolveToplevelImplItem::go): Take AssociatedItem as parameter.
	(ResolveTopLevelTraitItems::go): Likewise.
	* resolve/rust-ast-resolve-item.cc
	(ResolveTraitItems::go): Likewise.
	(ResolveItem::resolve_impl_item): Likewise.
	(ResolveImplItems::go): Likewise.
	* resolve/rust-ast-resolve-item.h
	(ResolveTraitItems::go): Likewise.
	(ResolveItem::resolve_impl_item): Likewise.
	(ResolveImplItems::go): Likewise.

Signed-off-by: Owen Avery <[email protected]>
  • Loading branch information
powerboat9 committed Oct 15, 2023
1 parent a792b95 commit 0cb6c3c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 40 deletions.
13 changes: 2 additions & 11 deletions gcc/rust/resolve/rust-ast-resolve-implitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,7 @@ class ResolveToplevelImplItem : public ResolverBase
using Rust::Resolver::ResolverBase::visit;

public:
static void go (AST::InherentImplItem *item, const CanonicalPath &prefix)
{
if (item->is_marked_for_strip ())
return;

ResolveToplevelImplItem resolver (prefix);
item->accept_vis (resolver);
}

static void go (AST::TraitImplItem *item, const CanonicalPath &prefix)
static void go (AST::AssociatedItem *item, const CanonicalPath &prefix)
{
if (item->is_marked_for_strip ())
return;
Expand Down Expand Up @@ -128,7 +119,7 @@ class ResolveTopLevelTraitItems : public ResolverBase
using Rust::Resolver::ResolverBase::visit;

public:
static void go (AST::TraitItem *item, const CanonicalPath &prefix,
static void go (AST::AssociatedItem *item, const CanonicalPath &prefix,
const CanonicalPath &canonical_prefix)
{
ResolveTopLevelTraitItems resolver (prefix, canonical_prefix);
Expand Down
25 changes: 3 additions & 22 deletions gcc/rust/resolve/rust-ast-resolve-item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ResolveTraitItems::ResolveTraitItems (const CanonicalPath &prefix,
{}

void
ResolveTraitItems::go (AST::TraitItem *item, const CanonicalPath &prefix,
ResolveTraitItems::go (AST::AssociatedItem *item, const CanonicalPath &prefix,
const CanonicalPath &canonical_prefix)
{
if (item->is_marked_for_strip ())
Expand Down Expand Up @@ -881,15 +881,7 @@ ResolveItem::visit (AST::ExternBlock &extern_block)
}

void
ResolveItem::resolve_impl_item (AST::TraitImplItem *item,
const CanonicalPath &prefix,
const CanonicalPath &canonical_prefix)
{
ResolveImplItems::go (item, prefix, canonical_prefix);
}

void
ResolveItem::resolve_impl_item (AST::InherentImplItem *item,
ResolveItem::resolve_impl_item (AST::AssociatedItem *item,
const CanonicalPath &prefix,
const CanonicalPath &canonical_prefix)
{
Expand Down Expand Up @@ -1062,18 +1054,7 @@ ResolveImplItems::ResolveImplItems (const CanonicalPath &prefix,
{}

void
ResolveImplItems::go (AST::InherentImplItem *item, const CanonicalPath &prefix,
const CanonicalPath &canonical_prefix)
{
if (item->is_marked_for_strip ())
return;

ResolveImplItems resolver (prefix, canonical_prefix);
item->accept_vis (resolver);
}

void
ResolveImplItems::go (AST::TraitImplItem *item, const CanonicalPath &prefix,
ResolveImplItems::go (AST::AssociatedItem *item, const CanonicalPath &prefix,
const CanonicalPath &canonical_prefix)
{
if (item->is_marked_for_strip ())
Expand Down
10 changes: 3 additions & 7 deletions gcc/rust/resolve/rust-ast-resolve-item.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ResolveTraitItems : public ResolverBase
using Rust::Resolver::ResolverBase::visit;

public:
static void go (AST::TraitItem *item, const CanonicalPath &prefix,
static void go (AST::AssociatedItem *item, const CanonicalPath &prefix,
const CanonicalPath &canonical_prefix);

void visit (AST::TraitItemType &type) override;
Expand Down Expand Up @@ -78,9 +78,7 @@ class ResolveItem : public ResolverBase
void visit (AST::UseDeclaration &) override;

protected:
void resolve_impl_item (AST::TraitImplItem *item, const CanonicalPath &prefix,
const CanonicalPath &canonical_prefix);
void resolve_impl_item (AST::InherentImplItem *item,
void resolve_impl_item (AST::AssociatedItem *item,
const CanonicalPath &prefix,
const CanonicalPath &canonical_prefix);
void resolve_extern_item (AST::ExternalItem *item);
Expand All @@ -97,9 +95,7 @@ class ResolveImplItems : public ResolveItem
using Rust::Resolver::ResolveItem::visit;

public:
static void go (AST::InherentImplItem *item, const CanonicalPath &prefix,
const CanonicalPath &canonical_prefix);
static void go (AST::TraitImplItem *item, const CanonicalPath &prefix,
static void go (AST::AssociatedItem *item, const CanonicalPath &prefix,
const CanonicalPath &canonical_prefix);

void visit (AST::TypeAlias &alias) override;
Expand Down

0 comments on commit 0cb6c3c

Please sign in to comment.