From: Pierre-Emmanuel Patry Date: Thu, 25 Apr 2024 13:39:33 +0000 (+0200) Subject: gccrs: Change return type of lookup_impl_block_type X-Git-Tag: basepoints/gcc-16~1439 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ead5584a07347847fea93fb5df7ba28fbce1b735;p=thirdparty%2Fgcc.git gccrs: Change return type of lookup_impl_block_type Change the return type to an optional. gcc/rust/ChangeLog: * typecheck/rust-type-util.cc (query_type): Adapt code to accomodate the new return type. * util/rust-hir-map.cc (Mappings::lookup_impl_block_type): Change the function's return type and remove the out pointer argument. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry --- diff --git a/gcc/rust/typecheck/rust-type-util.cc b/gcc/rust/typecheck/rust-type-util.cc index af38acd0c32..6847d87ad96 100644 --- a/gcc/rust/typecheck/rust-type-util.cc +++ b/gcc/rust/typecheck/rust-type-util.cc @@ -89,12 +89,10 @@ query_type (HirId reference, TyTy::BaseType **result) } // is it an impl_type? - HIR::ImplBlock *impl_block_by_type = nullptr; - bool found_impl_block_type - = mappings.lookup_impl_block_type (reference, &impl_block_by_type); - if (found_impl_block_type) + if (auto impl_block_by_type = mappings.lookup_impl_block_type (reference)) { - *result = TypeCheckItem::ResolveImplBlockSelf (*impl_block_by_type); + *result + = TypeCheckItem::ResolveImplBlockSelf (*impl_block_by_type.value ()); context->query_completed (reference); return true; } diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc index a5b1daf04c1..99c2493da14 100644 --- a/gcc/rust/util/rust-hir-map.cc +++ b/gcc/rust/util/rust-hir-map.cc @@ -486,15 +486,14 @@ Mappings::lookup_hir_impl_block (HirId id) return it->second; } -bool -Mappings::lookup_impl_block_type (HirId id, HIR::ImplBlock **impl_block) +tl::optional +Mappings::lookup_impl_block_type (HirId id) { auto it = hirImplBlockTypeMappings.find (id); if (it == hirImplBlockTypeMappings.end ()) - return false; + return tl::nullopt; - *impl_block = it->second; - return true; + return it->second; } void diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h index 109693e9c74..912d42a4b97 100644 --- a/gcc/rust/util/rust-hir-map.h +++ b/gcc/rust/util/rust-hir-map.h @@ -131,7 +131,7 @@ public: void insert_hir_impl_block (HIR::ImplBlock *item); tl::optional lookup_hir_impl_block (HirId id); - bool lookup_impl_block_type (HirId id, HIR::ImplBlock **impl_block); + tl::optional lookup_impl_block_type (HirId id); void insert_module (HIR::Module *module); HIR::Module *lookup_module (HirId id);