diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2024-04-25 16:00:23 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-17 16:35:24 +0100 |
commit | ddd0fb9e4bc725ba38396b36bfca0b143cb342f1 (patch) | |
tree | eb972a6e29f9b3fa79f15f0fe78ca69bca234d42 /gcc/rust/util/rust-hir-map.cc | |
parent | ead5584a07347847fea93fb5df7ba28fbce1b735 (diff) | |
download | gcc-ddd0fb9e4bc725ba38396b36bfca0b143cb342f1.zip gcc-ddd0fb9e4bc725ba38396b36bfca0b143cb342f1.tar.gz gcc-ddd0fb9e4bc725ba38396b36bfca0b143cb342f1.tar.bz2 |
gccrs: Change return type of lookup_crate_name
Change the function's return type to use an optional.
gcc/rust/ChangeLog:
* resolve/rust-ast-resolve-toplevel.h: Adapt the code to the new
return type.
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):
Likewise.
* rust-session-manager.cc (Session::load_extern_crate): Likewise.
* util/rust-hir-map.cc (Mappings::lookup_crate_name): Change the return
type to an optional.
* util/rust-hir-map.h: Update the function's prototype.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/util/rust-hir-map.cc')
-rw-r--r-- | gcc/rust/util/rust-hir-map.cc | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc index 99c2493..95d3b3a 100644 --- a/gcc/rust/util/rust-hir-map.cc +++ b/gcc/rust/util/rust-hir-map.cc @@ -164,19 +164,15 @@ Mappings::get_current_crate_name () const return name; } -bool -Mappings::lookup_crate_name (const std::string &crate_name, - CrateNum &resolved_crate_num) const +tl::optional<CrateNum> +Mappings::lookup_crate_name (const std::string &crate_name) const { for (const auto &it : crate_names) { if (it.second.compare (crate_name) == 0) - { - resolved_crate_num = it.first; - return true; - } + return it.first; } - return false; + return tl::nullopt; } bool |