From 0cb6c3cb1e12e37f27b384bb034e8dbfbae40b5c Mon Sep 17 00:00:00 2001 From: Owen Avery Date: Wed, 11 Oct 2023 15:06:21 -0400 Subject: [PATCH] Make resolution of AssociatedItem instances polymorphic 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 --- gcc/rust/resolve/rust-ast-resolve-implitem.h | 13 ++-------- gcc/rust/resolve/rust-ast-resolve-item.cc | 25 +++----------------- gcc/rust/resolve/rust-ast-resolve-item.h | 10 +++----- 3 files changed, 8 insertions(+), 40 deletions(-) diff --git a/gcc/rust/resolve/rust-ast-resolve-implitem.h b/gcc/rust/resolve/rust-ast-resolve-implitem.h index 9a34aa83889c..aa7ffe3d796b 100644 --- a/gcc/rust/resolve/rust-ast-resolve-implitem.h +++ b/gcc/rust/resolve/rust-ast-resolve-implitem.h @@ -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; @@ -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); diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc index baab62209994..3b730924c277 100644 --- a/gcc/rust/resolve/rust-ast-resolve-item.cc +++ b/gcc/rust/resolve/rust-ast-resolve-item.cc @@ -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 ()) @@ -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) { @@ -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 ()) diff --git a/gcc/rust/resolve/rust-ast-resolve-item.h b/gcc/rust/resolve/rust-ast-resolve-item.h index db47df5713a5..273d5c1c9efd 100644 --- a/gcc/rust/resolve/rust-ast-resolve-item.h +++ b/gcc/rust/resolve/rust-ast-resolve-item.h @@ -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; @@ -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); @@ -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;