Skip to content

Commit

Permalink
Fix small FixMe task in rust macro builtins
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
badumbatish authored and CohenArthur committed Feb 27, 2024
1 parent 4ef924f commit 75424e6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions gcc/rust/expand/rust-macro-builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/expand/rust-macro-builtins.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ enum class BuiltinMacro
Hash,
};

BuiltinMacro
tl::optional<BuiltinMacro>
builtin_macro_from_string (const std::string &identifier);

/**
Expand Down
2 changes: 1 addition & 1 deletion gcc/rust/resolve/rust-early-name-resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down

0 comments on commit 75424e6

Please sign in to comment.