aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-02-18 11:50:32 +0000
committerGitHub <noreply@github.com>2022-02-18 11:50:32 +0000
commit425905b49ae04bf0e00be95caa01fd6d2cc8e74c (patch)
tree83db64aeb7c1bf0002615e8f06e631a2e2682579
parentfbe22e87687c68357430e60361a8a124c81148cc (diff)
parentee4131396ebebf75280fe88a23c2d1778541376c (diff)
downloadgcc-425905b49ae04bf0e00be95caa01fd6d2cc8e74c.zip
gcc-425905b49ae04bf0e00be95caa01fd6d2cc8e74c.tar.gz
gcc-425905b49ae04bf0e00be95caa01fd6d2cc8e74c.tar.bz2
Merge #942
942: Removed Lambda Function within AST::PathPattern r=philberty a=mvvsmk Addresses issue #717 1) Changed the rust-path.h and removed the iterate_path_segments fuction. 2) Removed the lambda fuction form rust-ast-lower.cc and replaced it with a for loop. Do let me know if I missed anything or could improve on something. Signed-off-by : M V V S Manoj Kumar <mvvsmanojkumar@gmail.com> Co-authored-by: M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>
-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 (),