From 75424e6ccb57f69987a329e8df68f751af4bcc25 Mon Sep 17 00:00:00 2001 From: jjasmine Date: Fri, 23 Feb 2024 13:06:14 -0800 Subject: [PATCH] Fix small FixMe task in rust macro builtins gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc: Change BuiltinMacro in builtin_macro_from_string to tl::optional<> * expand/rust-macro-builtins.h (enum class): Change BuiltinMacro in builtin_macro_from_string to tl::optional<> * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Resolved wrong type dependency of builtin_macro_from_string Signed-off-by: jjasmine --- gcc/rust/expand/rust-macro-builtins.cc | 3 +-- gcc/rust/expand/rust-macro-builtins.h | 2 +- gcc/rust/resolve/rust-early-name-resolver.cc | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc index 2af05a5e3777..f103759acdd7 100644 --- a/gcc/rust/expand/rust-macro-builtins.cc +++ b/gcc/rust/expand/rust-macro-builtins.cc @@ -126,8 +126,7 @@ std::unordered_map {"Hash", MacroBuiltin::proc_macro_builtin}, }; -// FIXME: This should return an tl::optional -BuiltinMacro +tl::optional builtin_macro_from_string (const std::string &identifier) { auto macro = MacroBuiltin::builtins.lookup (identifier); diff --git a/gcc/rust/expand/rust-macro-builtins.h b/gcc/rust/expand/rust-macro-builtins.h index f9ab3fc3698e..1d6b30b59332 100644 --- a/gcc/rust/expand/rust-macro-builtins.h +++ b/gcc/rust/expand/rust-macro-builtins.h @@ -75,7 +75,7 @@ enum class BuiltinMacro Hash, }; -BuiltinMacro +tl::optional builtin_macro_from_string (const std::string &identifier); /** diff --git a/gcc/rust/resolve/rust-early-name-resolver.cc b/gcc/rust/resolve/rust-early-name-resolver.cc index 422dd92e4620..d70f9ca9806e 100644 --- a/gcc/rust/resolve/rust-early-name-resolver.cc +++ b/gcc/rust/resolve/rust-early-name-resolver.cc @@ -497,7 +497,7 @@ EarlyNameResolver::visit (AST::MacroInvocation &invoc) { auto builtin_kind = builtin_macro_from_string (rules_def->get_rule_name ().as_string ()); - invoc.map_to_builtin (builtin_kind); + invoc.map_to_builtin (builtin_kind.value ()); } auto attributes = rules_def->get_outer_attrs ();