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-25 10:48:47 +0200
committerP-E-P <32375388+P-E-P@users.noreply.github.com>2024-05-17 15:28:30 +0000
commit69e1835807dac79b426eb357e87191502d979657 (patch)
treea3f8871a55caf15a7957c60759235bc2fa3bb476 /gcc/rust/backend/rust-compile-resolve-path.cc
parent73f87d81c0ee1af1f9e9cc838e16653729173851 (diff)
downloadgcc-69e1835807dac79b426eb357e87191502d979657.zip
gcc-69e1835807dac79b426eb357e87191502d979657.tar.gz
gcc-69e1835807dac79b426eb357e87191502d979657.tar.bz2
Change return type for lookup_hir_item to optional
gcc/rust/ChangeLog: * backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): Adapt function call to new return type. * backend/rust-mangle-v0.cc (v0_path): Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::check_function_call): Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::check_use_of_static): Likewise. (UnsafeChecker::check_function_call): Likewise. (UnsafeChecker::check_function_attr): Likewise. * checks/lints/rust-lint-marklive.cc (MarkLive::go): Likewise. (MarkLive::visit): Likewise. * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_path_to_trait): Likewise. * typecheck/rust-type-util.cc (query_type): Likewise. * util/rust-hir-map.cc (Mappings::insert_hir_item): Likewise. (Mappings::lookup_hir_item): Change function return type to use optional. * util/rust-hir-map.h: Update function prototype. 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.cc8
1 files changed, 3 insertions, 5 deletions
diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc
index c9a2778..baef4d6 100644
--- a/gcc/rust/backend/rust-compile-resolve-path.cc
+++ b/gcc/rust/backend/rust-compile-resolve-path.cc
@@ -201,20 +201,18 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup,
const Analysis::NodeMapping &mappings,
location_t expr_locus, bool is_qualified_path)
{
- HIR::Item *resolved_item = ctx->get_mappings ().lookup_hir_item (ref);
HirId parent_block;
HIR::ExternalItem *resolved_extern_item
= ctx->get_mappings ().lookup_hir_extern_item (ref, &parent_block);
- bool is_hir_item = resolved_item != nullptr;
bool is_hir_extern_item = resolved_extern_item != nullptr;
bool is_fn = lookup->get_kind () == TyTy::TypeKind::FNDEF;
- if (is_hir_item)
+ if (auto resolved_item = ctx->get_mappings ().lookup_hir_item (ref))
{
if (!lookup->has_substitutions_defined ())
- return CompileItem::compile (resolved_item, ctx, nullptr, true,
+ return CompileItem::compile (*resolved_item, ctx, nullptr, true,
expr_locus);
else
- return CompileItem::compile (resolved_item, ctx, lookup, true,
+ return CompileItem::compile (*resolved_item, ctx, lookup, true,
expr_locus);
}
else if (is_hir_extern_item)