[gccrs COMMIT 2/4] Replace indexing with reverse iterator
gerris.rs@gmail.com
gerris.rs@gmail.com
Sun Sep 6 01:01:02 GMT 2026
From: Pierre-Emmanuel Patry <pierre.emmanuel.patry@opensrcsec.com>
This change makes the code a bit simpler, it comes from a series of patch
that got deleted and was iterating backward on the self segments.
gcc/rust/ChangeLog:
* resolve/rust-early-name-resolver-2.0.cc (Early::finalize_rebind_import):
Use a reverse iterator instead of an index.
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/cec82b879625ca04331785ca784ed48bf7af88ff
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/resolve/rust-early-name-resolver-2.0.cc | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
index 28e1d90a5..cb67af3e9 100644
--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
@@ -540,8 +540,11 @@ Early::finalize_rebind_import (const Early::ImportPair &mapping)
// Erroneous `self` or `{self}` use declaration
if (segments.size () == 1)
return;
- declared_name = segments[segments.size () - 2].as_string ();
- import_id = segments[segments.size () - 2].get_node_id ();
+
+ auto pre_self_segment = segments.rbegin () + 1;
+
+ declared_name = pre_self_segment->as_string ();
+ import_id = pre_self_segment->get_node_id ();
}
else
{
--
2.55.0
More information about the Gcc-rust
mailing list