public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8574] gccrs: Remove class AST::InherentImplItem
@ 2024-01-30 12:01 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-30 12:01 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:f84e564243915e729f22a5b6e4d1e4fb902f94f9
commit r14-8574-gf84e564243915e729f22a5b6e4d1e4fb902f94f9
Author: Owen Avery <powerboat9.gamer@gmail.com>
Date: Tue Nov 28 01:07:00 2023 -0500
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>
Diff:
---
gcc/rust/ast/rust-ast-full-decls.h | 1 -
gcc/rust/ast/rust-ast.cc | 4 ++--
gcc/rust/ast/rust-ast.h | 22 +++-------------------
gcc/rust/ast/rust-item.h | 18 ++++++++++--------
gcc/rust/ast/rust-macro.h | 2 +-
gcc/rust/expand/rust-expand-visitor.cc | 2 +-
gcc/rust/parse/rust-parse-impl.h | 8 ++++----
gcc/rust/parse/rust-parse.h | 4 ++--
8 files changed, 23 insertions(+), 38 deletions(-)
diff --git a/gcc/rust/ast/rust-ast-full-decls.h b/gcc/rust/ast/rust-ast-full-decls.h
index e2d05bae0c4b..5bfaaa8ba3c9 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 43820d38e283..17f82d674304 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 4049e4d26078..b193c67c69e5 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 3bf023b3c5a7..b34aca0d56cb 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 b3fdcf71417d..41c21cffa95d 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
{
diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc
index 3f598b7f21ce..1745af061746 100644
--- a/gcc/rust/expand/rust-expand-visitor.cc
+++ b/gcc/rust/expand/rust-expand-visitor.cc
@@ -1180,7 +1180,7 @@ ExpandVisitor::visit (AST::InherentImpl &impl)
if (impl.has_where_clause ())
expand_where_clause (impl.get_where_clause ());
- std::function<std::unique_ptr<AST::InherentImplItem> (AST::SingleASTNode)>
+ std::function<std::unique_ptr<AST::AssociatedItem> (AST::SingleASTNode)>
extractor = [] (AST::SingleASTNode node) { return node.take_impl_item (); };
expand_macro_children (MacroExpander::ContextType::IMPL,
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index f83cc122c893..a9af7dc3f389 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -5388,12 +5388,12 @@ Parser<ManagedTokenSource>::parse_impl (AST::Visibility vis,
AST::AttrVec inner_attrs = parse_inner_attributes ();
// parse inherent impl items
- std::vector<std::unique_ptr<AST::InherentImplItem>> impl_items;
+ std::vector<std::unique_ptr<AST::AssociatedItem>> impl_items;
const_TokenPtr t = lexer.peek_token ();
while (t->get_id () != RIGHT_CURLY)
{
- std::unique_ptr<AST::InherentImplItem> impl_item
+ std::unique_ptr<AST::AssociatedItem> impl_item
= parse_inherent_impl_item ();
if (impl_item == nullptr)
@@ -5512,7 +5512,7 @@ Parser<ManagedTokenSource>::parse_impl (AST::Visibility vis,
// Parses a single inherent impl item (item inside an inherent impl block).
template <typename ManagedTokenSource>
-std::unique_ptr<AST::InherentImplItem>
+std::unique_ptr<AST::AssociatedItem>
Parser<ManagedTokenSource>::parse_inherent_impl_item ()
{
// parse outer attributes (if they exist)
@@ -5629,7 +5629,7 @@ Parser<ManagedTokenSource>::parse_inherent_impl_item ()
// InherentImplItem is this specialisation of the template while TraitImplItem
// will be the other.
template <typename ManagedTokenSource>
-std::unique_ptr<AST::InherentImplItem>
+std::unique_ptr<AST::AssociatedItem>
Parser<ManagedTokenSource>::parse_inherent_impl_function_or_method (
AST::Visibility vis, AST::AttrVec outer_attrs)
{
diff --git a/gcc/rust/parse/rust-parse.h b/gcc/rust/parse/rust-parse.h
index d3718467b489..4291e4198a5f 100644
--- a/gcc/rust/parse/rust-parse.h
+++ b/gcc/rust/parse/rust-parse.h
@@ -170,7 +170,7 @@ public:
std::unique_ptr<AST::Type> parse_type (bool save_errors = true);
std::unique_ptr<AST::ExternalItem> parse_external_item ();
std::unique_ptr<AST::TraitItem> parse_trait_item ();
- std::unique_ptr<AST::InherentImplItem> parse_inherent_impl_item ();
+ std::unique_ptr<AST::AssociatedItem> parse_inherent_impl_item ();
std::unique_ptr<AST::TraitImplItem> parse_trait_impl_item ();
AST::PathInExpression parse_path_in_expression ();
std::vector<std::unique_ptr<AST::LifetimeParam>> parse_lifetime_params ();
@@ -348,7 +348,7 @@ private:
std::unique_ptr<AST::Impl> parse_impl (AST::Visibility vis,
AST::AttrVec outer_attrs);
- std::unique_ptr<AST::InherentImplItem>
+ std::unique_ptr<AST::AssociatedItem>
parse_inherent_impl_function_or_method (AST::Visibility vis,
AST::AttrVec outer_attrs);
std::unique_ptr<AST::TraitImplItem>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-30 12:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-30 12:01 [gcc r14-8574] gccrs: Remove class AST::InherentImplItem Arthur Cohen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).