diff mbox series

[021/125] gccrs: Fix small FixMe task in rust macro builtins

Message ID 20240801145809.366388-23-arthur.cohen@embecosm.com
State New
Headers show
Series [001/125] Rust: Make 'tree'-level 'MAIN_NAME_P' work | expand

Commit Message

Arthur Cohen Aug. 1, 2024, 2:56 p.m. UTC
From: jjasmine <tanghocle456@gmail.com>

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 <tanghocle456@gmail.com>
---
 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 mbox series

Patch

diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc
index 2af05a5e377..f103759acdd 100644
--- a/gcc/rust/expand/rust-macro-builtins.cc
+++ b/gcc/rust/expand/rust-macro-builtins.cc
@@ -126,8 +126,7 @@  std::unordered_map<std::string, AST::MacroTranscriberFunc>
     {"Hash", MacroBuiltin::proc_macro_builtin},
 };
 
-// FIXME: This should return an tl::optional
-BuiltinMacro
+tl::optional<BuiltinMacro>
 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 f9ab3fc3698..1d6b30b5933 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<BuiltinMacro>
 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 422dd92e462..d70f9ca9806 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 ();