Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make resolution of AssociatedItem instances polymorphic #2683

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading