aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-ast-fragment.cc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-06-02 11:41:53 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:46:26 +0100
commitf1afcf9fd5e85722766a803dac6c9e6bd90161cc (patch)
tree95dd933fdd287968b88406b90230504ae39f821a /gcc/rust/ast/rust-ast-fragment.cc
parent4ac118445077fca5153730740d7233b055821746 (diff)
downloadgcc-f1afcf9fd5e85722766a803dac6c9e6bd90161cc.zip
gcc-f1afcf9fd5e85722766a803dac6c9e6bd90161cc.tar.gz
gcc-f1afcf9fd5e85722766a803dac6c9e6bd90161cc.tar.bz2
gccrs: expand: Move derive system to new one
Builtin derive already had their own code scheme, incompatible with the proc macro pattern. This commit unifies derive macros with it. gcc/rust/ChangeLog: * ast/rust-ast-fragment.cc (Fragment::Fragment): Remove overwrite member in constructor. (Fragment::operator=): Removal of overwrite member in copy. (Fragment::should_overwrite): Remove overwrite getter. * ast/rust-ast-fragment.h: Remove overwrite boolean member. * expand/rust-expand-visitor.cc (derive_item): Add a function to derive items using the expander for now. (builtin_derive_item): Rename from derive_item to builtin_derive_item. (ExpandVisitor::visit): Remove visit to derive attributes. (ExpandVisitor::expand_derive): Remove derive attribute visitor. (ExpandVisitor::visit_attrs_with_derive): Likewise. * expand/rust-expand-visitor.h: Update insertion of other kind of proc macros. We no longer have an overwrite attribute in the fragment. * expand/rust-macro-expand.cc (MacroExpander::parse_procmacro_output): Return the fragment instead of inserting it. * expand/rust-macro-expand.h (struct MacroExpander): Return fragment. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/ast/rust-ast-fragment.cc')
-rw-r--r--gcc/rust/ast/rust-ast-fragment.cc18
1 files changed, 4 insertions, 14 deletions
diff --git a/gcc/rust/ast/rust-ast-fragment.cc b/gcc/rust/ast/rust-ast-fragment.cc
index e5d0cce..22d2e63 100644
--- a/gcc/rust/ast/rust-ast-fragment.cc
+++ b/gcc/rust/ast/rust-ast-fragment.cc
@@ -23,8 +23,7 @@ namespace AST {
Fragment::Fragment (FragmentKind kind, std::vector<SingleASTNode> nodes,
std::vector<std::unique_ptr<AST::Token>> tokens)
- : kind (kind), nodes (std::move (nodes)), tokens (std::move (tokens)),
- overwrite (true)
+ : kind (kind), nodes (std::move (nodes)), tokens (std::move (tokens))
{}
Fragment::Fragment (Fragment const &other) : kind (other.get_kind ())
@@ -47,8 +46,6 @@ Fragment::operator= (Fragment const &other)
for (auto &t : other.tokens)
tokens.emplace_back (t->clone_token ());
- overwrite = other.overwrite;
-
return *this;
}
@@ -59,15 +56,14 @@ Fragment::create_error ()
}
Fragment::Fragment (std::vector<AST::SingleASTNode> nodes,
- std::vector<std::unique_ptr<AST::Token>> tokens,
- bool overwrite)
+ std::vector<std::unique_ptr<AST::Token>> tokens)
: kind (FragmentKind::Complete), nodes (std::move (nodes)),
- tokens (std::move (tokens)), overwrite (overwrite)
+ tokens (std::move (tokens))
{}
Fragment::Fragment (std::vector<AST::SingleASTNode> nodes,
std::unique_ptr<AST::Token> token)
- : kind (FragmentKind::Complete), nodes (std::move (nodes)), overwrite (true)
+ : kind (FragmentKind::Complete), nodes (std::move (nodes))
{
tokens.emplace_back (std::move (token));
}
@@ -103,12 +99,6 @@ Fragment::should_expand () const
}
bool
-Fragment::should_overwrite () const
-{
- return overwrite;
-}
-
-bool
Fragment::is_expression_fragment () const
{
return is_single_fragment_of_kind (SingleASTNode::NodeType::EXPRESSION);