From 7146c1b6f5edfd7d0b92685d81c81fa1ec40ceab Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Thu, 25 Apr 2024 15:14:36 +0200 Subject: 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 --- gcc/rust/util/rust-hir-map.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/rust/util/rust-hir-map.cc') 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 Mappings::lookup_hir_extern_block (HirId id) { auto it = hirExternBlockMappings.find (id); if (it == hirExternBlockMappings.end ()) - return nullptr; + return tl::nullopt; return it->second; } -- cgit v1.1