aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/hir
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-02-27 13:35:50 +0100
committerCohenArthur <arthur.cohen@embecosm.com>2024-02-29 15:52:44 +0000
commite9de5b410da43cb2ac5f9865756153648e6f078b (patch)
treebaae5c1180b8fccafa02e67e89dee059f5368d80 /gcc/rust/hir
parent4e51e84d86629fa57ad8ac9849c4d582f442bb94 (diff)
downloadgcc-e9de5b410da43cb2ac5f9865756153648e6f078b.zip
gcc-e9de5b410da43cb2ac5f9865756153648e6f078b.tar.gz
gcc-e9de5b410da43cb2ac5f9865756153648e6f078b.tar.bz2
lang-items: Cleanup parsing and lookups of lang items.
gcc/rust/ChangeLog: * Make-lang.in: Compile new rust-lang-item.o. * util/rust-lang-item.h: Split into header and source. * util/rust-lang-item.cc: Cleanup parsing of lang items by using a hashmap and returning optional values, cleanup handling of exhaustive lang item lookups. * hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_lang_item_attribute): Use new optional API.
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r--gcc/rust/hir/rust-ast-lower-base.cc13
1 files changed, 6 insertions, 7 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-base.cc b/gcc/rust/hir/rust-ast-lower-base.cc
index 3ff0f52..815b98f 100644
--- a/gcc/rust/hir/rust-ast-lower-base.cc
+++ b/gcc/rust/hir/rust-ast-lower-base.cc
@@ -789,13 +789,12 @@ ASTLoweringBase::handle_lang_item_attribute (const ItemWrapper &item,
auto &literal = static_cast<AST::AttrInputLiteral &> (attr.get_attr_input ());
const auto &lang_item_type_str = literal.get_literal ().as_string ();
auto lang_item_type = Analysis::RustLangItem::Parse (lang_item_type_str);
- if (lang_item_type == Analysis::RustLangItem::ItemType::UNKNOWN)
- {
- rust_error_at (attr.get_locus (), "unknown lang item");
- return;
- }
- mappings->insert_lang_item (lang_item_type,
- item.get_mappings ().get_defid ());
+
+ if (lang_item_type)
+ mappings->insert_lang_item (*lang_item_type,
+ item.get_mappings ().get_defid ());
+ else
+ rust_error_at (attr.get_locus (), "unknown lang item");
}
bool