aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2024-12-26 23:00:08 +0000
committerCohenArthur <arthur.cohen@embecosm.com>2025-01-16 14:00:31 +0000
commit115df226360e769eefb5acc2a1f367e300546bdf (patch)
treeac459e58129b5bc5369d6685f0f3cd368750ea0d /gcc
parent68f142a0e92cc451d92e0bd9a4ca75dc50a7ff8f (diff)
downloadgcc-115df226360e769eefb5acc2a1f367e300546bdf.zip
gcc-115df226360e769eefb5acc2a1f367e300546bdf.tar.gz
gcc-115df226360e769eefb5acc2a1f367e300546bdf.tar.bz2
mappings: Add get_lang_item_node
This method errors out if the lang item has not been declared yet. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::get_lang_item_node): New. * util/rust-hir-map.h: New function.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/util/rust-hir-map.cc10
-rw-r--r--gcc/rust/util/rust-hir-map.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index 2edf099..bf09c94 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -1299,5 +1299,15 @@ Mappings::lookup_lang_item_node (LangItem::Kind item_type)
return it->second;
}
+NodeId
+Mappings::get_lang_item_node (LangItem::Kind item_type)
+{
+ if (auto lookup = lookup_lang_item_node (item_type))
+ return *lookup;
+
+ rust_fatal_error (UNKNOWN_LOCATION, "failed to find lang item %qs",
+ LangItem::ToString (item_type).c_str ());
+}
+
} // namespace Analysis
} // namespace Rust
diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h
index 6117b0a..9cf977a 100644
--- a/gcc/rust/util/rust-hir-map.h
+++ b/gcc/rust/util/rust-hir-map.h
@@ -261,6 +261,7 @@ public:
void insert_lang_item_node (LangItem::Kind item_type, NodeId node_id);
tl::optional<NodeId &> lookup_lang_item_node (LangItem::Kind item_type);
+ NodeId get_lang_item_node (LangItem::Kind item_type);
// This will fatal_error when this lang item does not exist
DefId get_lang_item (LangItem::Kind item_type, location_t locus);