aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-04-25 15:39:33 +0200
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2024-05-17 15:28:30 +0000
commit1be4fa36f08d8c48a78795948615ffcaeb27c8ac (patch)
tree54391bad103e2ec2cfba8c925baf217dbab62429 /gcc
parent9af30ca752f66063ce199d94e374bb9c7db4e65c (diff)
downloadgcc-1be4fa36f08d8c48a78795948615ffcaeb27c8ac.zip
gcc-1be4fa36f08d8c48a78795948615ffcaeb27c8ac.tar.gz
gcc-1be4fa36f08d8c48a78795948615ffcaeb27c8ac.tar.bz2
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 <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-type-util.cc8
-rw-r--r--gcc/rust/util/rust-hir-map.cc9
-rw-r--r--gcc/rust/util/rust-hir-map.h2
3 files changed, 8 insertions, 11 deletions
diff --git a/gcc/rust/typecheck/rust-type-util.cc b/gcc/rust/typecheck/rust-type-util.cc
index 7602d26..a278228 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 7ddceb7..f8a0cb4 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<HIR::ImplBlock *>
+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 17ee0fd..6d3763c 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<HIR::ImplBlock *> lookup_hir_impl_block (HirId id);
- bool lookup_impl_block_type (HirId id, HIR::ImplBlock **impl_block);
+ tl::optional<HIR::ImplBlock *> lookup_impl_block_type (HirId id);
void insert_module (HIR::Module *module);
HIR::Module *lookup_module (HirId id);