aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/util/rust-hir-map.cc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-05-03 20:48:10 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-17 16:35:25 +0100
commit058d76b9a84d70565743bec6513f1a86293ced2e (patch)
tree350e00c56f4a3d79d8e180730eecef93ebd2ee6c /gcc/rust/util/rust-hir-map.cc
parent2c08ad6c41cedc09401718060911198b025cd1ec (diff)
downloadgcc-058d76b9a84d70565743bec6513f1a86293ced2e.zip
gcc-058d76b9a84d70565743bec6513f1a86293ced2e.tar.gz
gcc-058d76b9a84d70565743bec6513f1a86293ced2e.tar.bz2
gccrs: Change lookup_hir_struct_field return type
Wrap the function's return type within an optional to differentiate between a null pointer and a missing value. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::insert_hir_struct_field): Change call site to accomodate new return type. (Mappings::lookup_hir_struct_field): Change the function's return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/util/rust-hir-map.cc')
-rw-r--r--gcc/rust/util/rust-hir-map.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index f124be8..d1f55a3 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -672,18 +672,18 @@ void
Mappings::insert_hir_struct_field (HIR::StructExprField *field)
{
auto id = field->get_mappings ().get_hirid ();
- rust_assert (lookup_hir_struct_field (id) == nullptr);
+ rust_assert (!lookup_hir_struct_field (id));
hirStructFieldMappings[id] = field;
insert_node_to_hir (field->get_mappings ().get_nodeid (), id);
}
-HIR::StructExprField *
+tl::optional<HIR::StructExprField *>
Mappings::lookup_hir_struct_field (HirId id)
{
auto it = hirStructFieldMappings.find (id);
if (it == hirStructFieldMappings.end ())
- return nullptr;
+ return tl::nullopt;
return it->second;
}