aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/util/rust-hir-map.cc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-04-25 16:15:42 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-17 16:35:24 +0100
commit8c5be0dd1c460694a2c8ef78bdadc2c6aea01ad8 (patch)
tree6fe0430c53f1d55cbb3eadfd67bf1bc998324305 /gcc/rust/util/rust-hir-map.cc
parentddd0fb9e4bc725ba38396b36bfca0b143cb342f1 (diff)
downloadgcc-8c5be0dd1c460694a2c8ef78bdadc2c6aea01ad8.zip
gcc-8c5be0dd1c460694a2c8ef78bdadc2c6aea01ad8.tar.gz
gcc-8c5be0dd1c460694a2c8ef78bdadc2c6aea01ad8.tar.bz2
gccrs: Change crate_num_to_nodeid return type
Change the function's return type to an optional. gcc/rust/ChangeLog: * resolve/rust-ast-resolve-toplevel.h: Adapt the code to the new return type. * rust-session-manager.cc (Session::load_extern_crate): Likewise. * util/rust-hir-map.cc (Mappings::crate_num_to_nodeid): Change the return type. * 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.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index 95d3b3a..76642a1 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -175,15 +175,14 @@ Mappings::lookup_crate_name (const std::string &crate_name) const
return tl::nullopt;
}
-bool
-Mappings::crate_num_to_nodeid (const CrateNum &crate_num, NodeId &node_id) const
+tl::optional<NodeId>
+Mappings::crate_num_to_nodeid (const CrateNum &crate_num) const
{
auto it = ast_crate_mappings.find (crate_num);
if (it == ast_crate_mappings.end ())
- return false;
+ return tl::nullopt;
- node_id = it->second->get_node_id ();
- return true;
+ return it->second->get_node_id ();
}
bool