aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/expand
diff options
context:
space:
mode:
authorSourabh Jaiswal <sourabhrj31@gmail.com>2024-03-01 19:46:23 +0800
committerArthur Cohen <arthur.cohen@embecosm.com>2024-08-01 13:12:14 +0200
commit8c642618265162c28a9de83ba4df12318023fda7 (patch)
tree0f9d0fc131c37336cdc82c215ce7635c8383318a /gcc/rust/expand
parentebbf7bedbabc2a52fd0cd2b97611eb5d9bf02086 (diff)
downloadgcc-8c642618265162c28a9de83ba4df12318023fda7.zip
gcc-8c642618265162c28a9de83ba4df12318023fda7.tar.gz
gcc-8c642618265162c28a9de83ba4df12318023fda7.tar.bz2
gccrs: Clean BiMap to use tl::optional for lookups
gcc/rust/Changelog: * expand/rust-expand-visitor.cc (ExpandVisitor::expand_inner_items): Adjust to use has_value () (ExpandVisitor::expand_inner_stmts): Likewise * expand/rust-macro-builtins.cc (builtin_macro_from_string): Likewise (make_macro_path_str): Likewise * util/rust-hir-map.cc (Mappings::insert_macro_def): Likewise * util/rust-lang-item.cc (LangItem::Parse): Adjust to return tl::optional (LangItem::toString) Likewise * util/rust-token-converter.cc (handle_suffix): Adjust to use value.or () (from_literal) Likewise * util/bi-map.h (BiMap::lookup): Adjust to use tl::optional for lookups Signed-off-by: Sourabh Jaiswal <sourabhrj31@gmail.com>
Diffstat (limited to 'gcc/rust/expand')
-rw-r--r--gcc/rust/expand/rust-expand-visitor.cc8
-rw-r--r--gcc/rust/expand/rust-macro-builtins.cc8
2 files changed, 8 insertions, 8 deletions
diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc
index 6ca6311..bd49fd9 100644
--- a/gcc/rust/expand/rust-expand-visitor.cc
+++ b/gcc/rust/expand/rust-expand-visitor.cc
@@ -186,11 +186,11 @@ ExpandVisitor::expand_inner_items (
{
auto maybe_builtin = MacroBuiltin::builtins.lookup (
to_derive.get ().as_string ());
- if (MacroBuiltin::builtins.is_iter_ok (maybe_builtin))
+ if (maybe_builtin.has_value ())
{
auto new_item
= builtin_derive_item (*item, current,
- maybe_builtin->second);
+ maybe_builtin.value ());
// this inserts the derive *before* the item - is it a
// problem?
it = items.insert (it, std::move (new_item));
@@ -272,11 +272,11 @@ ExpandVisitor::expand_inner_stmts (AST::BlockExpr &expr)
{
auto maybe_builtin = MacroBuiltin::builtins.lookup (
to_derive.get ().as_string ());
- if (MacroBuiltin::builtins.is_iter_ok (maybe_builtin))
+ if (maybe_builtin.has_value ())
{
auto new_item
= builtin_derive_item (item, current,
- maybe_builtin->second);
+ maybe_builtin.value ());
// this inserts the derive *before* the item - is it a
// problem?
it = stmts.insert (it, std::move (new_item));
diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc
index e4ca0d8..8cf3205 100644
--- a/gcc/rust/expand/rust-macro-builtins.cc
+++ b/gcc/rust/expand/rust-macro-builtins.cc
@@ -142,9 +142,9 @@ tl::optional<BuiltinMacro>
builtin_macro_from_string (const std::string &identifier)
{
auto macro = MacroBuiltin::builtins.lookup (identifier);
- rust_assert (MacroBuiltin::builtins.is_iter_ok (macro));
+ rust_assert (macro.has_value ());
- return macro->second;
+ return macro;
}
namespace {
@@ -152,9 +152,9 @@ std::string
make_macro_path_str (BuiltinMacro kind)
{
auto str = MacroBuiltin::builtins.lookup (kind);
- rust_assert (MacroBuiltin::builtins.is_iter_ok (str));
+ rust_assert (str.has_value ());
- return str->second;
+ return str.value ();
}
static std::vector<std::unique_ptr<AST::MacroInvocation>>