Some construct are forbidden in trait context (eg. pub, async...) and
we'll need to reject those. To do so we need to identify a trait context.
gcc/rust/ChangeLog:
* ast/rust-ast-visitor.cc (ContextualASTVisitor::visit): Push the new
trait context when visiting a trait.
* ast/rust-ast-visitor.h: Add visit function prototype and TRAIT
context.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
pop_context ();
}
+void
+ContextualASTVisitor::visit (AST::Trait &trait)
+{
+ push_context (Context::TRAIT);
+ DefaultASTVisitor::visit (trait);
+ pop_context ();
+}
+
} // namespace AST
} // namespace Rust
FUNCTION,
INHERENT_IMPL,
TRAIT_IMPL,
+ TRAIT,
MODULE,
CRATE,
};
virtual void visit (AST::TraitImpl &impl) override;
+ virtual void visit (AST::Trait &trait) override;
+
template <typename T> void visit (T &item)
{
DefaultASTVisitor::visit (item);