From 4dd34b1fd1241afeeb4fa7e6f5848a6c1af5430b Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Fri, 3 May 2024 19:40:18 +0200 Subject: gccrs: Change lookup_hir_expr return type to optional Wrap the function's return type with an optional in order to differentiate missing values from null pointers. gcc/rust/ChangeLog: * backend/rust-mangle-v0.cc (v0_path): Adapt call site to new returned type. * util/rust-hir-map.cc (Mappings::lookup_hir_expr): Change the function's return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/backend/rust-mangle-v0.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'gcc/rust/backend') diff --git a/gcc/rust/backend/rust-mangle-v0.cc b/gcc/rust/backend/rust-mangle-v0.cc index 261e844..d604dcf 100644 --- a/gcc/rust/backend/rust-mangle-v0.cc +++ b/gcc/rust/backend/rust-mangle-v0.cc @@ -384,8 +384,6 @@ v0_path (Rust::Compile::Context *ctx, const TyTy::BaseType *ty, auto hir_id = hid.value (); - HIR::Expr *expr = mappings.lookup_hir_expr (hir_id); - if (auto impl_item = mappings.lookup_hir_implitem (hir_id)) { switch (impl_item->first->get_impl_item_type ()) @@ -467,9 +465,9 @@ v0_path (Rust::Compile::Context *ctx, const TyTy::BaseType *ty, cpath.get ().c_str ()); break; } - else if (expr != nullptr) + else if (auto expr = mappings.lookup_hir_expr (hir_id)) { - rust_assert (expr->get_expression_type () + rust_assert (expr.value ()->get_expression_type () == HIR::Expr::ExprType::Closure); // Use HIR ID as disambiguator. v0path = v0_closure (v0path, hir_id); -- cgit v1.1