diff options
author | Owen Avery <powerboat9.gamer@gmail.com> | 2023-11-28 01:07:00 -0500 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-30 12:36:47 +0100 |
commit | f84e564243915e729f22a5b6e4d1e4fb902f94f9 (patch) | |
tree | 68127f79aae4a51bcef8c16126e97dd650771942 /gcc/rust/ast | |
parent | b4fc851e3a01e708819ebfe1bfe4f2dc2ae9e5e7 (diff) | |
download | gcc-f84e564243915e729f22a5b6e4d1e4fb902f94f9.zip gcc-f84e564243915e729f22a5b6e4d1e4fb902f94f9.tar.gz gcc-f84e564243915e729f22a5b6e4d1e4fb902f94f9.tar.bz2 |
gccrs: Remove class AST::InherentImplItem
gcc/rust/ChangeLog:
* ast/rust-ast-full-decls.h
(class InherentImplItem): Remove.
* ast/rust-ast.h
(class InherentImplItem): Remove.
(class SingleASTNode):
Store pointer to AssociatedItem instead of InherentImplItem.
* ast/rust-ast.cc
(SingleASTNode::SingleASTNode):
Use clone_associated_item instead of clone_inherent_impl_item.
(SingleASTNode::operator=): Likewise.
* ast/rust-item.h
(class InherentImpl):
Use AssociatedItem rather than InherentImplItem.
(class Function): Likewise.
(class ConstantItem): Likewise.
* ast/rust-macro.h
(class MacroInvocation): Likewise.
* expand/rust-expand-visitor.cc
(ExpandVisitor::visit): Likewise.
* parse/rust-parse-impl.h
(Parser::parse_impl): Likewise.
(Parser::parse_inherent_impl_item): Likewise.
(Parser::parse_inherent_impl_function_or_method): Likewise.
* parse/rust-parse.h
(Parser::parse_inherent_impl_item): Likewise.
(Parser::parse_inherent_impl_function_or_method): Likewise.
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Diffstat (limited to 'gcc/rust/ast')
-rw-r--r-- | gcc/rust/ast/rust-ast-full-decls.h | 1 | ||||
-rw-r--r-- | gcc/rust/ast/rust-ast.cc | 4 | ||||
-rw-r--r-- | gcc/rust/ast/rust-ast.h | 22 | ||||
-rw-r--r-- | gcc/rust/ast/rust-item.h | 18 | ||||
-rw-r--r-- | gcc/rust/ast/rust-macro.h | 2 |
5 files changed, 16 insertions, 31 deletions
diff --git a/gcc/rust/ast/rust-ast-full-decls.h b/gcc/rust/ast/rust-ast-full-decls.h index e2d05ba..5bfaaa8 100644 --- a/gcc/rust/ast/rust-ast-full-decls.h +++ b/gcc/rust/ast/rust-ast-full-decls.h @@ -52,7 +52,6 @@ class GenericParam; class LifetimeParam; class ConstGenericParam; class TraitItem; -class InherentImplItem; class TraitImplItem; struct Crate; class PathExpr; diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc index 43820d3..17f82d6 100644 --- a/gcc/rust/ast/rust-ast.cc +++ b/gcc/rust/ast/rust-ast.cc @@ -64,7 +64,7 @@ SingleASTNode::SingleASTNode (SingleASTNode const &other) break; case IMPL: - impl_item = other.impl_item->clone_inherent_impl_item (); + impl_item = other.impl_item->clone_associated_item (); break; case TRAIT_IMPL: @@ -104,7 +104,7 @@ SingleASTNode::operator= (SingleASTNode const &other) break; case IMPL: - impl_item = other.impl_item->clone_inherent_impl_item (); + impl_item = other.impl_item->clone_associated_item (); break; case TRAIT_IMPL: diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 4049e4d..b193c67 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -1687,22 +1687,6 @@ public: location_t get_locus () const override { return locus; } }; -/* Abstract base class for items used within an inherent impl block (the impl - * name {} one) */ -class InherentImplItem : virtual public AssociatedItem -{ -protected: - // Clone function implementation as pure virtual method - virtual InherentImplItem *clone_associated_item_impl () const override = 0; - -public: - // Unique pointer custom clone function - std::unique_ptr<InherentImplItem> clone_inherent_impl_item () const - { - return std::unique_ptr<InherentImplItem> (clone_associated_item_impl ()); - } -}; - // Abstract base class for items used in a trait impl class TraitImplItem : virtual public AssociatedItem { @@ -1860,7 +1844,7 @@ private: std::unique_ptr<Stmt> stmt; std::unique_ptr<ExternalItem> external_item; std::unique_ptr<TraitItem> trait_item; - std::unique_ptr<InherentImplItem> impl_item; + std::unique_ptr<AssociatedItem> impl_item; std::unique_ptr<TraitImplItem> trait_impl_item; std::unique_ptr<Type> type; @@ -1885,7 +1869,7 @@ public: : kind (TRAIT), trait_item (std::move (item)) {} - SingleASTNode (std::unique_ptr<InherentImplItem> item) + SingleASTNode (std::unique_ptr<AssociatedItem> item) : kind (IMPL), impl_item (std::move (item)) {} @@ -1959,7 +1943,7 @@ public: return std::move (external_item); } - std::unique_ptr<InherentImplItem> take_impl_item () + std::unique_ptr<AssociatedItem> take_impl_item () { rust_assert (!is_error ()); return std::move (impl_item); diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index 3bf023b..b34aca0 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -1285,7 +1285,9 @@ protected: class LetStmt; // Rust function declaration AST node -class Function : public VisItem, public InherentImplItem, public TraitImplItem +class Function : public VisItem, + virtual public AssociatedItem, + public TraitImplItem { FunctionQualifiers qualifiers; Identifier function_name; @@ -2308,7 +2310,7 @@ protected: /* "Constant item" AST node - used for constant, compile-time expressions * within module scope (like constexpr) */ class ConstantItem : public VisItem, - public InherentImplItem, + virtual public AssociatedItem, public TraitImplItem { // either has an identifier or "_" - maybe handle in identifier? @@ -3408,7 +3410,7 @@ protected: class InherentImpl : public Impl { // bool has_impl_items; - std::vector<std::unique_ptr<InherentImplItem>> impl_items; + std::vector<std::unique_ptr<AssociatedItem>> impl_items; public: std::string as_string () const override; @@ -3417,7 +3419,7 @@ public: bool has_impl_items () const { return !impl_items.empty (); } // Mega-constructor - InherentImpl (std::vector<std::unique_ptr<InherentImplItem>> impl_items, + InherentImpl (std::vector<std::unique_ptr<AssociatedItem>> impl_items, std::vector<std::unique_ptr<GenericParam>> generic_params, std::unique_ptr<Type> trait_type, WhereClause where_clause, Visibility vis, std::vector<Attribute> inner_attrs, @@ -3433,7 +3435,7 @@ public: { impl_items.reserve (other.impl_items.size ()); for (const auto &e : other.impl_items) - impl_items.push_back (e->clone_inherent_impl_item ()); + impl_items.push_back (e->clone_associated_item ()); } // Overloaded assignment operator with vector clone @@ -3443,7 +3445,7 @@ public: impl_items.reserve (other.impl_items.size ()); for (const auto &e : other.impl_items) - impl_items.push_back (e->clone_inherent_impl_item ()); + impl_items.push_back (e->clone_associated_item ()); return *this; } @@ -3455,11 +3457,11 @@ public: void accept_vis (ASTVisitor &vis) override; // TODO: think of better way to do this - const std::vector<std::unique_ptr<InherentImplItem>> &get_impl_items () const + const std::vector<std::unique_ptr<AssociatedItem>> &get_impl_items () const { return impl_items; } - std::vector<std::unique_ptr<InherentImplItem>> &get_impl_items () + std::vector<std::unique_ptr<AssociatedItem>> &get_impl_items () { return impl_items; } diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h index b3fdcf7..41c21cf 100644 --- a/gcc/rust/ast/rust-macro.h +++ b/gcc/rust/ast/rust-macro.h @@ -599,7 +599,7 @@ class MacroInvocation : public TypeNoBounds, public Item, public TraitItem, public TraitImplItem, - public InherentImplItem, + virtual public AssociatedItem, public ExternalItem, public ExprWithoutBlock { |