From 16bf7555b6f4ab0d588ec26b7b1a9001ae59928f Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Thu, 2 May 2024 13:44:10 +0200 Subject: gccrs: Change lookup_hir_extern_item return type Wrap the return type with an optional and make the return type a pair with the parent hid. gcc/rust/ChangeLog: * backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): Adapt code around new return type. * 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. * typecheck/rust-type-util.cc (query_type): Likewise. * util/rust-hir-map.cc (Mappings::insert_hir_extern_item): Likewise. (Mappings::lookup_hir_extern_item): Change return type. * util/rust-hir-map.h: Update the function's prototype. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/backend/rust-compile-resolve-path.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'gcc/rust/backend') diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc index bf294e4..c27074f 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.cc +++ b/gcc/rust/backend/rust-compile-resolve-path.cc @@ -201,10 +201,6 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, const Analysis::NodeMapping &mappings, location_t expr_locus, bool is_qualified_path) { - HirId parent_block; - HIR::ExternalItem *resolved_extern_item - = ctx->get_mappings ().lookup_hir_extern_item (ref, &parent_block); - bool is_hir_extern_item = resolved_extern_item != nullptr; bool is_fn = lookup->get_kind () == TyTy::TypeKind::FNDEF; if (auto resolved_item = ctx->get_mappings ().lookup_hir_item (ref)) { @@ -215,8 +211,10 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, return CompileItem::compile (*resolved_item, ctx, lookup, true, expr_locus); } - else if (is_hir_extern_item) + else if (auto hir_extern_item + = ctx->get_mappings ().lookup_hir_extern_item (ref)) { + HIR::ExternalItem *resolved_extern_item = hir_extern_item->first; if (!lookup->has_substitutions_defined ()) return CompileExternItem::compile (resolved_extern_item, ctx, nullptr, true, expr_locus); -- cgit v1.1