aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/rust/ast/rust-path.h9
-rw-r--r--gcc/rust/hir/rust-ast-lower.cc41
2 files changed, 21 insertions, 29 deletions
diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h
index ed37f40..a189872 100644
--- a/gcc/rust/ast/rust-path.h
+++ b/gcc/rust/ast/rust-path.h
@@ -305,15 +305,6 @@ public:
// TODO: this seems kinda dodgy
std::vector<PathExprSegment> &get_segments () { return segments; }
const std::vector<PathExprSegment> &get_segments () const { return segments; }
-
- void iterate_path_segments (std::function<bool (PathExprSegment &)> cb)
- {
- for (auto it = segments.begin (); it != segments.end (); it++)
- {
- if (!cb (*it))
- return;
- }
- }
};
/* AST node representing a path-in-expression pattern (path that allows generic
diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc
index c4db0a3..aac6ee5 100644
--- a/gcc/rust/hir/rust-ast-lower.cc
+++ b/gcc/rust/hir/rust-ast-lower.cc
@@ -263,17 +263,17 @@ void
ASTLowerPathInExpression::visit (AST::PathInExpression &expr)
{
std::vector<HIR::PathExprSegment> path_segments;
- expr.iterate_path_segments ([&] (AST::PathExprSegment &s) mutable -> bool {
- path_segments.push_back (lower_path_expr_seg (s));
-
- // insert the mappings for the segment
- HIR::PathExprSegment *lowered_seg = &path_segments.back ();
- mappings->insert_hir_path_expr_seg (
- lowered_seg->get_mappings ().get_crate_num (),
- lowered_seg->get_mappings ().get_hirid (), lowered_seg);
- return true;
- });
+ auto &segments = expr.get_segments ();
+ for (auto &s : segments)
+ {
+ path_segments.push_back (lower_path_expr_seg ((s)));
+ // insert the mappings for the segment
+ HIR::PathExprSegment *lowered_seg = &path_segments.back ();
+ mappings->insert_hir_path_expr_seg (
+ lowered_seg->get_mappings ().get_crate_num (),
+ lowered_seg->get_mappings ().get_hirid (), lowered_seg);
+ }
auto crate_num = mappings->get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
mappings->get_next_hir_id (crate_num),
@@ -311,16 +311,17 @@ ASTLowerQualPathInExpression::visit (AST::QualifiedPathInExpression &expr)
= lower_qual_path_type (expr.get_qualified_path_type ());
std::vector<HIR::PathExprSegment> path_segments;
- expr.iterate_path_segments ([&] (AST::PathExprSegment &s) mutable -> bool {
- path_segments.push_back (lower_path_expr_seg (s));
-
- // insert the mappings for the segment
- HIR::PathExprSegment *lowered_seg = &path_segments.back ();
- mappings->insert_hir_path_expr_seg (
- lowered_seg->get_mappings ().get_crate_num (),
- lowered_seg->get_mappings ().get_hirid (), lowered_seg);
- return true;
- });
+ auto &segments = expr.get_segments ();
+ for (auto &s : segments)
+ {
+ path_segments.push_back (lower_path_expr_seg ((s)));
+
+ // insert the mappings for the segment
+ HIR::PathExprSegment *lowered_seg = &path_segments.back ();
+ mappings->insert_hir_path_expr_seg (
+ lowered_seg->get_mappings ().get_crate_num (),
+ lowered_seg->get_mappings ().get_hirid (), lowered_seg);
+ }
auto crate_num = mappings->get_current_crate ();
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),