diff --git a/gcc/rust/checks/errors/rust-feature-gate.cc b/gcc/rust/checks/errors/rust-feature-gate.cc index 91ef85edfba7..f1f82edfa043 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 ca61199403f1..a6380854bc36 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 @@ class FeatureGate : public AST::ASTVisitor 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 {}