From: Pierre-Emmanuel Patry Date: Fri, 3 May 2024 18:42:06 +0000 (+0200) Subject: Change lookup_hir_self_param return type X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d8efec4f7b85e8d73eebe24a4667c702b7fb6f2;p=thirdparty%2Fgcc.git Change lookup_hir_self_param return type Wrap the function's return type within an optional in order to differentiate null pointers from missing value. gcc/rust/ChangeLog: * util/rust-hir-map.cc (Mappings::insert_hir_self_param): Adapt call site to new return type. (Mappings::lookup_hir_self_param): Change the function's return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry --- diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc index 3fb649603739..c2c75abeb801 100644 --- a/gcc/rust/util/rust-hir-map.cc +++ b/gcc/rust/util/rust-hir-map.cc @@ -652,18 +652,18 @@ void Mappings::insert_hir_self_param (HIR::SelfParam *param) { auto id = param->get_mappings ().get_hirid (); - rust_assert (lookup_hir_self_param (id) == nullptr); + rust_assert (!lookup_hir_self_param (id)); hirSelfParamMappings[id] = param; insert_node_to_hir (param->get_mappings ().get_nodeid (), id); } -HIR::SelfParam * +tl::optional Mappings::lookup_hir_self_param (HirId id) { auto it = hirSelfParamMappings.find (id); if (it == hirSelfParamMappings.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 f8c3cb1809c4..7e1f644b11ec 100644 --- a/gcc/rust/util/rust-hir-map.h +++ b/gcc/rust/util/rust-hir-map.h @@ -164,7 +164,7 @@ public: tl::optional lookup_hir_param (HirId id); void insert_hir_self_param (HIR::SelfParam *type); - HIR::SelfParam *lookup_hir_self_param (HirId id); + tl::optional lookup_hir_self_param (HirId id); void insert_hir_struct_field (HIR::StructExprField *type); HIR::StructExprField *lookup_hir_struct_field (HirId id);