aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/util
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-04-25 15:14:36 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-17 16:35:23 +0100
commit7146c1b6f5edfd7d0b92685d81c81fa1ec40ceab (patch)
tree59e133719893ce9990cca652cc3afdc28bb8ac81 /gcc/rust/util
parent7b90f5e5212b056dfac763b6a4e79b533dbe4f2b (diff)
downloadgcc-7146c1b6f5edfd7d0b92685d81c81fa1ec40ceab.zip
gcc-7146c1b6f5edfd7d0b92685d81c81fa1ec40ceab.tar.gz
gcc-7146c1b6f5edfd7d0b92685d81c81fa1ec40ceab.tar.bz2
gccrs: Change return type of lookup_hir_extern_block
Change the return type to an optional in order to easily differentiate between a null pointer and an missing value. gcc/rust/ChangeLog: * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::check_function_call): Adapt function call to new return type. * typecheck/rust-type-util.cc (query_type): Likewise. * util/rust-hir-map.cc (Mappings::insert_hir_extern_block): Likewise. (Mappings::lookup_hir_extern_block): Change return type to an optional. * 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')
-rw-r--r--gcc/rust/util/rust-hir-map.cc6
-rw-r--r--gcc/rust/util/rust-hir-map.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index 0d134bf..184ab13 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -426,18 +426,18 @@ void
Mappings::insert_hir_extern_block (HIR::ExternBlock *block)
{
auto id = block->get_mappings ().get_hirid ();
- rust_assert (lookup_hir_extern_block (id) == nullptr);
+ rust_assert (!lookup_hir_extern_block (id).has_value ());
hirExternBlockMappings[id] = block;
insert_node_to_hir (block->get_mappings ().get_nodeid (), id);
}
-HIR::ExternBlock *
+tl::optional<HIR::ExternBlock *>
Mappings::lookup_hir_extern_block (HirId id)
{
auto it = hirExternBlockMappings.find (id);
if (it == hirExternBlockMappings.end ())
- return nullptr;
+ return tl::nullopt;
return it->second;
}
diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h
index 5565ef9..ef4d656 100644
--- a/gcc/rust/util/rust-hir-map.h
+++ b/gcc/rust/util/rust-hir-map.h
@@ -124,7 +124,7 @@ public:
tl::optional<HIR::TraitItem *> lookup_hir_trait_item (HirId id);
void insert_hir_extern_block (HIR::ExternBlock *block);
- HIR::ExternBlock *lookup_hir_extern_block (HirId id);
+ tl::optional<HIR::ExternBlock *> lookup_hir_extern_block (HirId id);
void insert_hir_extern_item (HIR::ExternalItem *item, HirId parent_block);
HIR::ExternalItem *lookup_hir_extern_item (HirId id, HirId *parent_block);