#include "rust-ast-validation.h"
#include "rust-diagnostics.h"
+#include "rust-keyword-values.h"
namespace Rust {
-namespace {
-// TODO: make constexpr when update to c++20
-const std::map<std::string, TokenId> keywords = {
-#define RS_TOKEN(x, y)
-#define RS_TOKEN_KEYWORD(tok, key) {key, tok},
- RS_TOKEN_LIST
-#undef RS_TOKEN_KEYWORD
-#undef RS_TOKEN
-};
-} // namespace
-
void
ASTValidation::visit (AST::Lifetime &lifetime)
{
auto name = lifetime.get_lifetime_name ();
auto valid = std::set<std::string>{"static", "_"};
+ auto &keywords = Values::Keywords::keywords;
+
if (valid.find (name) == valid.end ()
&& keywords.find (name) != keywords.end ())
rust_error_at (lifetime.get_locus (), "lifetimes cannot use keyword names");