https://gcc.gnu.org/g:cfe4e50a944a44253767d9a06f62eb64ef9f6b2d
commit r17-5930-gcfe4e50a944a44253767d9a06f62eb64ef9f6b2d Author: Pierre-Emmanuel Patry <[email protected]> Date: Wed Oct 28 12:35:48 2026 +0100 gccrs: Replace additional segment vectors with UtilPath gcc/rust/ChangeLog: * resolve/rust-forever-stack.h: Replace vector with UtilPath. * resolve/rust-forever-stack.hxx: Likewise. * resolve/rust-name-resolution-context.h: Likewise. * resolve/rust-name-resolution-context.hxx: Likewise. Signed-off-by: Pierre-Emmanuel Patry <[email protected]> Diff: --- gcc/rust/resolve/rust-forever-stack.h | 2 +- gcc/rust/resolve/rust-forever-stack.hxx | 3 ++- gcc/rust/resolve/rust-name-resolution-context.h | 2 +- gcc/rust/resolve/rust-name-resolution-context.hxx | 10 +++++++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gcc/rust/resolve/rust-forever-stack.h b/gcc/rust/resolve/rust-forever-stack.h index 0f9874eb8e09..c45159bd6c5a 100644 --- a/gcc/rust/resolve/rust-forever-stack.h +++ b/gcc/rust/resolve/rust-forever-stack.h @@ -786,7 +786,7 @@ public: Node &find_closest_module (Node &starting_point); tl::optional<SegIterator> - find_starting_point (const std::vector<ResolutionPath::Segment> &segments, + find_starting_point (const UtilPath<ResolutionPath::Segment> &path, std::reference_wrapper<Node> &starting_point, std::function<void (Usage, Definition, Namespace)> insert_segment_resolution, diff --git a/gcc/rust/resolve/rust-forever-stack.hxx b/gcc/rust/resolve/rust-forever-stack.hxx index 6a1bd93dde6e..00d2d6ce4484 100644 --- a/gcc/rust/resolve/rust-forever-stack.hxx +++ b/gcc/rust/resolve/rust-forever-stack.hxx @@ -466,11 +466,12 @@ check_leading_kw_at_start (std::vector<Error> &collect_errors, template <Namespace N> tl::optional<typename std::vector<ResolutionPath::Segment>::const_iterator> ForeverStack<N>::find_starting_point ( - const std::vector<ResolutionPath::Segment> &segments, + const UtilPath<ResolutionPath::Segment> &path, std::reference_wrapper<Node> &starting_point, std::function<void (Usage, Definition, Namespace)> insert_segment_resolution, std::vector<Error> &collect_errors) { + auto &segments = path.get_segments (); auto iterator = segments.begin (); for (; iterator != segments.end (); iterator++) diff --git a/gcc/rust/resolve/rust-name-resolution-context.h b/gcc/rust/resolve/rust-name-resolution-context.h index 62b31d9b1eaf..cddf01ddb698 100644 --- a/gcc/rust/resolve/rust-name-resolution-context.h +++ b/gcc/rust/resolve/rust-name-resolution-context.h @@ -944,7 +944,7 @@ private: tl::optional<typename ForeverStack<N>::Node &> resolve_segments (ForeverStack<N> &stack, typename ForeverStack<N>::Node &starting_point, - const std::vector<ResolutionPath::Segment> &segments, + const UtilPath<ResolutionPath::Segment> &path, typename ForeverStack<N>::SegIterator iterator, std::function<void (Usage, Definition, Namespace)> insert_segment_resolution, diff --git a/gcc/rust/resolve/rust-name-resolution-context.hxx b/gcc/rust/resolve/rust-name-resolution-context.hxx index a92f15d7b40e..568e9b70504a 100644 --- a/gcc/rust/resolve/rust-name-resolution-context.hxx +++ b/gcc/rust/resolve/rust-name-resolution-context.hxx @@ -190,9 +190,12 @@ NameResolutionContext::resolve_path ( } auto iterator = segments.begin (); + auto util_path + = UtilPath<ResolutionPath::Segment> (segments, + path.has_opening_scope_resolution ()); if (can_descend) { - if (auto res = stack.find_starting_point (segments, starting_point, + if (auto res = stack.find_starting_point (util_path, starting_point, insert_segment_resolution, collect_errors)) iterator = *res; @@ -214,7 +217,7 @@ NameResolutionContext::resolve_path ( // nodes are shared between stacks auto node - = resolve_segments (types, starting_point.get (), segments, iterator, + = resolve_segments (types, starting_point.get (), util_path, iterator, insert_segment_resolution, collect_errors); if (!node) @@ -249,12 +252,13 @@ template <Namespace N> tl::optional<typename ForeverStack<N>::Node &> NameResolutionContext::resolve_segments ( ForeverStack<N> &stack, typename ForeverStack<N>::Node &starting_point, - const std::vector<ResolutionPath::Segment> &segments, + const UtilPath<ResolutionPath::Segment> &path, typename ForeverStack<N>::SegIterator iterator, std::function<void (Usage, Definition, Namespace)> insert_segment_resolution, std::vector<Error> &collect_errors) { auto *current_node = &starting_point; + auto &segments = path.get_segments (); for (; !is_last (iterator, segments); iterator++) { auto &seg = *iterator;
