public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8581] gccrs: Make feature gate visitor inherit from default one
@ 2024-01-30 11:59 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-30 11:59 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:9f6d3010047d417f54c439db42f111fa61b216df
commit r14-8581-g9f6d3010047d417f54c439db42f111fa61b216df
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date: Fri Nov 24 11:17:52 2023 +0100
gccrs: Make feature gate visitor inherit from default one
The feature gating behavior may be shortened and kept cleaner using the
default visitor. This means less maintenance on visit functions as the
traversal is shared by multiple visitors.
gcc/rust/ChangeLog:
* checks/errors/rust-feature-gate.cc (FeatureGate::visit): Add a visit
function for the crate level.
(FeatureGate::check): Add call to crate visit.
* checks/errors/rust-feature-gate.h (class FeatureGate): Remove now
useless visit functions (traversal only).
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diff:
---
gcc/rust/checks/errors/rust-feature-gate.cc | 37 +++++++----------------------
gcc/rust/checks/errors/rust-feature-gate.h | 7 +++---
2 files changed, 13 insertions(+), 31 deletions(-)
diff --git a/gcc/rust/checks/errors/rust-feature-gate.cc b/gcc/rust/checks/errors/rust-feature-gate.cc
index a531d0370f00..3c943022f05e 100644
--- a/gcc/rust/checks/errors/rust-feature-gate.cc
+++ b/gcc/rust/checks/errors/rust-feature-gate.cc
@@ -18,11 +18,18 @@
#include "rust-feature-gate.h"
#include "rust-abi.h"
+#include "rust-ast-visitor.h"
namespace Rust {
void
FeatureGate::check (AST::Crate &crate)
+{
+ visit (crate);
+}
+
+void
+FeatureGate::visit (AST::Crate &crate)
{
valid_features.clear ();
@@ -56,12 +63,7 @@ FeatureGate::check (AST::Crate &crate)
}
}
- auto &items = crate.items;
- for (auto it = items.begin (); it != items.end (); it++)
- {
- auto &item = *it;
- item->accept_vis (*this);
- }
+ AST::DefaultASTVisitor::visit (crate);
}
void
@@ -103,10 +105,7 @@ FeatureGate::visit (AST::ExternBlock &block)
gate (Feature::Name::INTRINSICS, block.get_locus (),
"intrinsics are subject to change");
}
- for (const auto &item : block.get_extern_items ())
- {
- item->accept_vis (*this);
- }
+ AST::DefaultASTVisitor::visit (block);
}
void
@@ -129,24 +128,6 @@ FeatureGate::visit (AST::MacroRulesDefinition &rules_def)
check_rustc_attri (rules_def.get_outer_attrs ());
}
-void
-FeatureGate::visit (AST::InherentImpl &impl)
-{
- for (const auto &item : impl.get_impl_items ())
- {
- item->accept_vis (*this);
- }
-}
-
-void
-FeatureGate::visit (AST::TraitImpl &impl)
-{
- for (const auto &item : impl.get_impl_items ())
- {
- item->accept_vis (*this);
- }
-}
-
void
FeatureGate::visit (AST::Function &function)
{
diff --git a/gcc/rust/checks/errors/rust-feature-gate.h b/gcc/rust/checks/errors/rust-feature-gate.h
index 1ebd3c9e05fb..8d1a26a13619 100644
--- a/gcc/rust/checks/errors/rust-feature-gate.h
+++ b/gcc/rust/checks/errors/rust-feature-gate.h
@@ -25,12 +25,15 @@
namespace Rust {
-class FeatureGate : public AST::ASTVisitor
+class FeatureGate : public AST::DefaultASTVisitor
{
public:
FeatureGate () {}
+ using AST::DefaultASTVisitor::visit;
+
void check (AST::Crate &crate);
+ void visit (AST::Crate &crate) override;
void visit (AST::Token &tok) override {}
void visit (AST::DelimTokenTree &delim_tok_tree) override {}
@@ -127,8 +130,6 @@ public:
void visit (AST::TraitItemConst &item) override {}
void visit (AST::TraitItemType &item) override {}
void visit (AST::Trait &trait) override {}
- void visit (AST::InherentImpl &impl) override;
- void visit (AST::TraitImpl &impl) override;
void visit (AST::ExternalTypeItem &item) override;
void visit (AST::ExternalStaticItem &item) override {}
void visit (AST::ExternalFunctionItem &item) override {}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-30 11:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-30 11:59 [gcc r14-8581] gccrs: Make feature gate visitor inherit from default one 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).