From c4c46f5fd7fa26b3bd5cf653a66ffa9cbb8cb24e Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Thu, 25 Apr 2024 15:28:32 +0200 Subject: gccrs: Change return type for lookup_hir_impl_block Change the return type to an optiona. This allows to differentiate between missing hir impl block and null pointers. gcc/rust/ChangeLog: * typecheck/rust-type-util.cc (query_type): Change call to the function in order to accomodate the new return type. * util/rust-hir-map.cc (Mappings::lookup_hir_impl_block): Change the function's return type to an optional. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/util/rust-hir-map.cc | 6 +++--- gcc/rust/util/rust-hir-map.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'gcc/rust/util') diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc index 184ab13..a5b1daf 100644 --- a/gcc/rust/util/rust-hir-map.cc +++ b/gcc/rust/util/rust-hir-map.cc @@ -468,7 +468,7 @@ void Mappings::insert_hir_impl_block (HIR::ImplBlock *item) { auto id = item->get_mappings ().get_hirid (); - rust_assert (lookup_hir_impl_block (id) == nullptr); + rust_assert (!lookup_hir_impl_block (id)); HirId impl_type_id = item->get_type ()->get_mappings ().get_hirid (); hirImplBlockMappings[id] = item; @@ -476,12 +476,12 @@ Mappings::insert_hir_impl_block (HIR::ImplBlock *item) insert_node_to_hir (item->get_mappings ().get_nodeid (), id); } -HIR::ImplBlock * +tl::optional Mappings::lookup_hir_impl_block (HirId id) { auto it = hirImplBlockMappings.find (id); if (it == hirImplBlockMappings.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 ef4d656..109693e 100644 --- a/gcc/rust/util/rust-hir-map.h +++ b/gcc/rust/util/rust-hir-map.h @@ -130,7 +130,7 @@ public: HIR::ExternalItem *lookup_hir_extern_item (HirId id, HirId *parent_block); void insert_hir_impl_block (HIR::ImplBlock *item); - HIR::ImplBlock *lookup_hir_impl_block (HirId id); + tl::optional lookup_hir_impl_block (HirId id); bool lookup_impl_block_type (HirId id, HIR::ImplBlock **impl_block); void insert_module (HIR::Module *module); -- cgit v1.1