diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2024-04-25 10:48:47 +0200 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2024-05-17 15:28:30 +0000 |
commit | 69e1835807dac79b426eb357e87191502d979657 (patch) | |
tree | a3f8871a55caf15a7957c60759235bc2fa3bb476 /gcc/rust/backend/rust-mangle-v0.cc | |
parent | 73f87d81c0ee1af1f9e9cc838e16653729173851 (diff) | |
download | gcc-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-mangle-v0.cc')
-rw-r--r-- | gcc/rust/backend/rust-mangle-v0.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/gcc/rust/backend/rust-mangle-v0.cc b/gcc/rust/backend/rust-mangle-v0.cc index bb2b0d4..f7a8191 100644 --- a/gcc/rust/backend/rust-mangle-v0.cc +++ b/gcc/rust/backend/rust-mangle-v0.cc @@ -387,7 +387,6 @@ v0_path (Rust::Compile::Context *ctx, const TyTy::BaseType *ty, HIR::ImplItem *impl_item = mappings.lookup_hir_implitem (hir_id, &parent_impl_id); HIR::TraitItem *trait_item = mappings.lookup_hir_trait_item (hir_id); - HIR::Item *item = mappings.lookup_hir_item (hir_id); HIR::Expr *expr = mappings.lookup_hir_expr (hir_id); if (impl_item != nullptr) @@ -428,11 +427,11 @@ v0_path (Rust::Compile::Context *ctx, const TyTy::BaseType *ty, break; } } - else if (item != nullptr) - switch (item->get_item_kind ()) + else if (auto item = mappings.lookup_hir_item (hir_id)) + switch (item.value ()->get_item_kind ()) { case HIR::Item::ItemKind::Function: { - HIR::Function *fn = static_cast<HIR::Function *> (item); + HIR::Function *fn = static_cast<HIR::Function *> (*item); v0path = v0_function_path (v0path, ctx, ty, fn, v0_identifier (seg.get ())); } @@ -453,7 +452,7 @@ v0_path (Rust::Compile::Context *ctx, const TyTy::BaseType *ty, case HIR::Item::ItemKind::Impl: // Trait impl or inherent impl. { - HIR::ImplBlock *impl_block = static_cast<HIR::ImplBlock *> (item); + HIR::ImplBlock *impl_block = static_cast<HIR::ImplBlock *> (*item); v0path = v0_inherent_or_trait_impl_path (ctx, impl_block); } break; |