aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/checks/errors/rust-ast-validation.cc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-10-26 13:30:28 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 19:13:11 +0100
commit222f27d3ac159f1c56b670f336fb515e84491df4 (patch)
treead9ba66147028eb829fd229c446b02bbc45404a4 /gcc/rust/checks/errors/rust-ast-validation.cc
parentddcd4c96757d1f9a962b24eca61cac3f8068a155 (diff)
downloadgcc-222f27d3ac159f1c56b670f336fb515e84491df4.zip
gcc-222f27d3ac159f1c56b670f336fb515e84491df4.tar.gz
gcc-222f27d3ac159f1c56b670f336fb515e84491df4.tar.bz2
gccrs: Make use of the Contextual visitor in validation
Use the new contextual ast visitor to reduce the amount of code in the ast validation visitor. gcc/rust/ChangeLog: * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Adapt the call to the new visit functions. (ASTValidation::check): Launch the parent class visitor root function. * checks/errors/rust-ast-validation.h (class ASTValidation): Inherit from the contextual visitor. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/checks/errors/rust-ast-validation.cc')
-rw-r--r--gcc/rust/checks/errors/rust-ast-validation.cc48
1 files changed, 1 insertions, 47 deletions
diff --git a/gcc/rust/checks/errors/rust-ast-validation.cc b/gcc/rust/checks/errors/rust-ast-validation.cc
index c9498a4..92822fe 100644
--- a/gcc/rust/checks/errors/rust-ast-validation.cc
+++ b/gcc/rust/checks/errors/rust-ast-validation.cc
@@ -21,53 +21,6 @@
namespace Rust {
-template <typename T>
-void
-ASTValidation::visit (T &node)
-{
- node.accept_vis (*this);
-}
-
-template <typename T>
-void
-ASTValidation::visit (std::unique_ptr<T> &node)
-{
- node->accept_vis (*this);
-}
-
-void
-ASTValidation::check (AST::Crate &crate)
-{
- push_context (Context::CRATE);
- for (auto &item : crate.items)
- {
- visit (item);
- }
- pop_context ();
-}
-
-void
-ASTValidation::visit (AST::InherentImpl &impl)
-{
- push_context (Context::INHERENT_IMPL);
- for (auto &item : impl.get_impl_items ())
- {
- visit (item);
- }
- pop_context ();
-}
-
-void
-ASTValidation::visit (AST::TraitImpl &impl)
-{
- push_context (Context::TRAIT_IMPL);
- for (auto &item : impl.get_impl_items ())
- {
- visit (item);
- }
- pop_context ();
-}
-
void
ASTValidation::visit (AST::ConstantItem &const_item)
{
@@ -76,6 +29,7 @@ ASTValidation::visit (AST::ConstantItem &const_item)
rust_error_at (const_item.get_locus (),
"associated constant in %<impl%> without body");
}
+ AST::ContextualASTVisitor::visit (const_item);
}
} // namespace Rust