From: Owen Avery Date: Mon, 11 Nov 2024 21:04:58 +0000 (-0500) Subject: gccrs: Fix ForeverStack::find_starting_point output parameter X-Git-Tag: basepoints/gcc-16~990 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=588ded8766e16fe2e9c2a657935cde519dad454e;p=thirdparty%2Fgcc.git gccrs: Fix ForeverStack::find_starting_point output parameter gcc/rust/ChangeLog: * resolve/rust-forever-stack.h (ForeverStack::find_starting_point): Use type 'std::reference_wrapper &' 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 --- diff --git a/gcc/rust/resolve/rust-forever-stack.h b/gcc/rust/resolve/rust-forever-stack.h index c548eeae087..064d1ab2bb3 100644 --- a/gcc/rust/resolve/rust-forever-stack.h +++ b/gcc/rust/resolve/rust-forever-stack.h @@ -614,7 +614,8 @@ private: template tl::optional> - find_starting_point (const std::vector &segments, Node &starting_point); + find_starting_point (const std::vector &segments, + std::reference_wrapper &starting_point); template tl::optional resolve_segments (Node &starting_point, diff --git a/gcc/rust/resolve/rust-forever-stack.hxx b/gcc/rust/resolve/rust-forever-stack.hxx index 58164a4d328..d3d78894671 100644 --- a/gcc/rust/resolve/rust-forever-stack.hxx +++ b/gcc/rust/resolve/rust-forever-stack.hxx @@ -374,8 +374,8 @@ check_leading_kw_at_start (const S &segment, bool condition) template template tl::optional::const_iterator> -ForeverStack::find_starting_point (const std::vector &segments, - Node &starting_point) +ForeverStack::find_starting_point ( + const std::vector &segments, std::reference_wrapper &starting_point) { auto iterator = segments.begin (); @@ -412,14 +412,15 @@ ForeverStack::find_starting_point (const std::vector &segments, } if (seg.is_super_path_seg ()) { - if (starting_point.is_root ()) + if (starting_point.get ().is_root ()) { rust_error_at (seg.get_locus (), ErrorCode::E0433, "too many leading % keywords"); return tl::nullopt; } - starting_point = find_closest_module (starting_point.parent.value ()); + starting_point + = find_closest_module (starting_point.get ().parent.value ()); continue; } @@ -494,12 +495,12 @@ ForeverStack::resolve_path (const std::vector &segments) if (segments.size () == 1) return get (segments.back ().as_string ()); - auto starting_point = cursor (); + std::reference_wrapper starting_point = cursor (); return find_starting_point (segments, starting_point) .and_then ([this, &segments, &starting_point] ( typename std::vector::const_iterator iterator) { - return resolve_segments (starting_point, segments, iterator); + return resolve_segments (starting_point.get (), segments, iterator); }) .and_then ([&segments] (Node final_node) { return final_node.rib.get (segments.back ().as_string ());