aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-mangle-v0.cc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-04-24 21:27:26 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-17 16:35:23 +0100
commit709371a1f09dd77a292a8555134aa2c54ce74728 (patch)
tree5d2e6d58f1b053fb37e8fda9a05d24db492aff13 /gcc/rust/backend/rust-mangle-v0.cc
parentd6e6d2b3df75690de5648d23a5d6a1eb88feaaf9 (diff)
downloadgcc-709371a1f09dd77a292a8555134aa2c54ce74728.zip
gcc-709371a1f09dd77a292a8555134aa2c54ce74728.tar.gz
gcc-709371a1f09dd77a292a8555134aa2c54ce74728.tar.bz2
gccrs: 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-mangle-v0.cc')
-rw-r--r--gcc/rust/backend/rust-mangle-v0.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/gcc/rust/backend/rust-mangle-v0.cc b/gcc/rust/backend/rust-mangle-v0.cc
index 0c85d42..b2f11b1 100644
--- a/gcc/rust/backend/rust-mangle-v0.cc
+++ b/gcc/rust/backend/rust-mangle-v0.cc
@@ -374,14 +374,15 @@ v0_path (Rust::Compile::Context *ctx, const TyTy::BaseType *ty,
V0Path v0path = {};
cpath.iterate_segs ([&] (const Resolver::CanonicalPath &seg) {
- HirId hir_id;
- bool ok = mappings.lookup_node_to_hir (seg.get_node_id (), &hir_id);
- if (!ok)
+ tl::optional<HirId> hid = mappings.lookup_node_to_hir (seg.get_node_id ());
+ if (!hid.has_value ())
{
// FIXME: generic arg in canonical path? (e.g. <i32> in crate::S<i32>)
rust_unreachable ();
}
+ auto hir_id = hid.value ();
+
HirId parent_impl_id = UNKNOWN_HIRID;
HIR::ImplItem *impl_item
= mappings.lookup_hir_implitem (hir_id, &parent_impl_id);