aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-resolve-path.cc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-04-24 21:27:26 +0200
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2024-05-17 15:28:30 +0000
commit6dff797adfaac68b063da06024d42d357d6069a6 (patch)
treec55cef385ef9f60700cc972222692d2b51963d79 /gcc/rust/backend/rust-compile-resolve-path.cc
parentc7687ef1f7a9d2683bb45dcbf547b42aae856075 (diff)
downloadgcc-6dff797adfaac68b063da06024d42d357d6069a6.zip
gcc-6dff797adfaac68b063da06024d42d357d6069a6.tar.gz
gcc-6dff797adfaac68b063da06024d42d357d6069a6.tar.bz2
Change lookup_node_to_hir return type to optional
Previous API was using a boolean and a pointer, this was not practical and could be replaced with an optional. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Change call to use the returned optional. (CompileExpr::generate_closure_function): Likewise. * backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve): Likewise. * backend/rust-compile-type.cc (TyTyResolveCompile::visit): Likewise. * backend/rust-mangle-v0.cc (v0_path): Likewise. * checks/errors/privacy/rust-visibility-resolver.cc: Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise. * checks/lints/rust-lint-marklive.cc (MarkLive::visit): Likewise. (MarkLive::visit_path_segment): Likewise. * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait): Likewise. * typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path): Likewise. * typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): Likewise. (ResolveWhereClauseItem::visit): Likewise. * util/rust-hir-map.cc (Mappings::lookup_node_to_hir): Return an optional instead of a boolean. * util/rust-hir-map.h: Change function prototype to match the new return type. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-resolve-path.cc')
-rw-r--r--gcc/rust/backend/rust-compile-resolve-path.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc
index 182b5fe..c9a2778 100644
--- a/gcc/rust/backend/rust-compile-resolve-path.cc
+++ b/gcc/rust/backend/rust-compile-resolve-path.cc
@@ -125,12 +125,14 @@ ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment,
expr_locus);
}
- HirId ref;
- if (!ctx->get_mappings ().lookup_node_to_hir (ref_node_id, &ref))
+ tl::optional<HirId> hid
+ = ctx->get_mappings ().lookup_node_to_hir (ref_node_id);
+ if (!hid.has_value ())
{
rust_error_at (expr_locus, "reverse call path lookup failure");
return error_mark_node;
}
+ auto ref = hid.value ();
// might be a constant
tree constant_expr;