From: Pierre-Emmanuel Patry <[email protected]>
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]>
Tested on x86_64-pc-linux-gnu.
---
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 0f9874eb8e0..c45159bd6c5 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 6a1bd93dde6..00d2d6ce448 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 62b31d9b1ea..cddf01ddb69 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 a92f15d7b40..568e9b70504 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;
--
2.55.0