]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Replace local keyword set with the utils
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 8 Nov 2023 09:57:48 +0000 (10:57 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:13:13 +0000 (19:13 +0100)
We don't require that local set anymore.

gcc/rust/ChangeLog:

* checks/errors/rust-ast-validation.cc (RS_TOKEN): Remove locale set.
(RS_TOKEN_KEYWORD): Likewise.
(ASTValidation::visit): Change keyword set call to the one from utils.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/checks/errors/rust-ast-validation.cc

index d27d3e861ef9f47679352cafe35b6fab911e9f73..3af5655d7f318d67aa106ec131ffba484f4e934a 100644 (file)
 
 #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");