Skip to content

Commit e6e62d4

Browse files
powerboat9CohenArthur
authored andcommitted
Fix ForeverStack::find_starting_point output parameter
gcc/rust/ChangeLog: * resolve/rust-forever-stack.h (ForeverStack::find_starting_point): Use type 'std::reference_wrapper<Node> &' instead of 'Node &' for parameter starting_point. * resolve/rust-forever-stack.hxx (ForeverStack::find_starting_point): Likewise. (ForeverStack::resolve_path): Handle change to ForeverStack::find_starting_point. Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
1 parent 1995c83 commit e6e62d4

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

gcc/rust/resolve/rust-forever-stack.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,8 @@ template <Namespace N> class ForeverStack
614614

615615
template <typename S>
616616
tl::optional<SegIterator<S>>
617-
find_starting_point (const std::vector<S> &segments, Node &starting_point);
617+
find_starting_point (const std::vector<S> &segments,
618+
std::reference_wrapper<Node> &starting_point);
618619

619620
template <typename S>
620621
tl::optional<Node &> resolve_segments (Node &starting_point,

gcc/rust/resolve/rust-forever-stack.hxx

+7-6
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ check_leading_kw_at_start (const S &segment, bool condition)
374374
template <Namespace N>
375375
template <typename S>
376376
tl::optional<typename std::vector<S>::const_iterator>
377-
ForeverStack<N>::find_starting_point (const std::vector<S> &segments,
378-
Node &starting_point)
377+
ForeverStack<N>::find_starting_point (
378+
const std::vector<S> &segments, std::reference_wrapper<Node> &starting_point)
379379
{
380380
auto iterator = segments.begin ();
381381

@@ -412,14 +412,15 @@ ForeverStack<N>::find_starting_point (const std::vector<S> &segments,
412412
}
413413
if (seg.is_super_path_seg ())
414414
{
415-
if (starting_point.is_root ())
415+
if (starting_point.get ().is_root ())
416416
{
417417
rust_error_at (seg.get_locus (), ErrorCode::E0433,
418418
"too many leading %<super%> keywords");
419419
return tl::nullopt;
420420
}
421421

422-
starting_point = find_closest_module (starting_point.parent.value ());
422+
starting_point
423+
= find_closest_module (starting_point.get ().parent.value ());
423424
continue;
424425
}
425426

@@ -494,12 +495,12 @@ ForeverStack<N>::resolve_path (const std::vector<S> &segments)
494495
if (segments.size () == 1)
495496
return get (segments.back ().as_string ());
496497

497-
auto starting_point = cursor ();
498+
std::reference_wrapper<Node> starting_point = cursor ();
498499

499500
return find_starting_point (segments, starting_point)
500501
.and_then ([this, &segments, &starting_point] (
501502
typename std::vector<S>::const_iterator iterator) {
502-
return resolve_segments (starting_point, segments, iterator);
503+
return resolve_segments (starting_point.get (), segments, iterator);
503504
})
504505
.and_then ([&segments] (Node final_node) {
505506
return final_node.rib.get (segments.back ().as_string ());

0 commit comments

Comments
 (0)