[gccrs COMMIT 1/4] Simplify crate number lookup
gerris.rs@gmail.com
gerris.rs@gmail.com
Sun Sep 6 01:01:01 GMT 2026
From: Pierre-Emmanuel Patry <pierre.emmanuel.patry@opensrcsec.com>
Uses the hir mapping getter instead of directly using the set.
gcc/rust/ChangeLog:
* util/rust-hir-map.cc (Mappings::get_ast_crate_by_node_id_raw): Use
appropriate getter.
Signed-off-by: Pierre-Emmanuel Patry <pierre.emmanuel.patry@opensrcsec.com>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github: https://github.com/Rust-GCC/gccrs/commit/25f56e0fa4dc9e48eaa87f43874538fa66d5d4fb
The commit has NOT been mentioned in any issue.
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4844
gcc/rust/util/rust-hir-map.cc | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index 87fca310e..3d8da522e 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -258,10 +258,7 @@ Mappings::get_ast_crate_by_node_id (NodeId id)
AST::Crate *
Mappings::get_ast_crate_by_node_id_raw (NodeId id)
{
- auto i = crate_node_to_crate_num.find (id);
- rust_assert (i != crate_node_to_crate_num.end ());
-
- CrateNum crateNum = i->second;
+ CrateNum crateNum = lookup_crate_num (id).value ();
auto it = ast_crate_mappings.find (crateNum);
rust_assert (it != ast_crate_mappings.end ());
return it->second;
base-commit: 3fc990f97c8abf7b224e6dfad76a8e786d174358
--
2.55.0
More information about the Gcc-rust
mailing list