]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Change lookup_hir_generic_param return type
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Fri, 3 May 2024 17:59:43 +0000 (19:59 +0200)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Fri, 17 May 2024 15:28:30 +0000 (15:28 +0000)
Wrap the function's return type with an optional.

gcc/rust/ChangeLog:

* util/rust-hir-map.cc (Mappings::insert_hir_generic_param): Change
call site to accomodate the new return type.
(Mappings::lookup_hir_generic_param): Wrap the function's return type
with an optional.
* util/rust-hir-map.h: Update the function's prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/util/rust-hir-map.cc
gcc/rust/util/rust-hir-map.h

index 02e24bedfec6c0de6baf4416fb336a1a75a457e0..457e8af8ef0190ff44fff3b783101a86b881b38b 100644 (file)
@@ -571,19 +571,19 @@ void
 Mappings::insert_hir_generic_param (HIR::GenericParam *param)
 {
   auto id = param->get_mappings ().get_hirid ();
-  rust_assert (lookup_hir_generic_param (id) == nullptr);
+  rust_assert (!lookup_hir_generic_param (id));
 
   hirGenericParamMappings[id] = param;
   insert_node_to_hir (param->get_mappings ().get_nodeid (), id);
   insert_location (id, param->get_locus ());
 }
 
-HIR::GenericParam *
+tl::optional<HIR::GenericParam *>
 Mappings::lookup_hir_generic_param (HirId id)
 {
   auto it = hirGenericParamMappings.find (id);
   if (it == hirGenericParamMappings.end ())
-    return nullptr;
+    return tl::nullopt;
 
   return it->second;
 }
index dbfc8c05b7df38fd07bfce620a7549ee491b50ad..2c15097e0ce4d6758429610fcabd738ad9783df3 100644 (file)
@@ -152,7 +152,7 @@ public:
   tl::optional<HIR::PathExprSegment *> lookup_hir_path_expr_seg (HirId id);
 
   void insert_hir_generic_param (HIR::GenericParam *expr);
-  HIR::GenericParam *lookup_hir_generic_param (HirId id);
+  tl::optional<HIR::GenericParam *> lookup_hir_generic_param (HirId id);
 
   void insert_hir_type (HIR::Type *type);
   HIR::Type *lookup_hir_type (HirId id);