Skip to content

Commit ee41313

Browse files
committed
Removed Lambda Function within AST::PathPattern
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. Signed-off-by : M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>
1 parent b71cc52 commit ee41313

File tree

2 files changed

+21
-29
lines changed

2 files changed

+21
-29
lines changed

gcc/rust/ast/rust-path.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,6 @@ class PathPattern : public Pattern
303303
// TODO: this seems kinda dodgy
304304
std::vector<PathExprSegment> &get_segments () { return segments; }
305305
const std::vector<PathExprSegment> &get_segments () const { return segments; }
306-
307-
void iterate_path_segments (std::function<bool (PathExprSegment &)> cb)
308-
{
309-
for (auto it = segments.begin (); it != segments.end (); it++)
310-
{
311-
if (!cb (*it))
312-
return;
313-
}
314-
}
315306
};
316307

317308
/* AST node representing a path-in-expression pattern (path that allows generic

gcc/rust/hir/rust-ast-lower.cc

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,17 @@ void
263263
ASTLowerPathInExpression::visit (AST::PathInExpression &expr)
264264
{
265265
std::vector<HIR::PathExprSegment> path_segments;
266-
expr.iterate_path_segments ([&] (AST::PathExprSegment &s) mutable -> bool {
267-
path_segments.push_back (lower_path_expr_seg (s));
268-
269-
// insert the mappings for the segment
270-
HIR::PathExprSegment *lowered_seg = &path_segments.back ();
271-
mappings->insert_hir_path_expr_seg (
272-
lowered_seg->get_mappings ().get_crate_num (),
273-
lowered_seg->get_mappings ().get_hirid (), lowered_seg);
274-
return true;
275-
});
266+
auto &segments = expr.get_segments ();
267+
for (auto &s : segments)
268+
{
269+
path_segments.push_back (lower_path_expr_seg ((s)));
276270

271+
// insert the mappings for the segment
272+
HIR::PathExprSegment *lowered_seg = &path_segments.back ();
273+
mappings->insert_hir_path_expr_seg (
274+
lowered_seg->get_mappings ().get_crate_num (),
275+
lowered_seg->get_mappings ().get_hirid (), lowered_seg);
276+
}
277277
auto crate_num = mappings->get_current_crate ();
278278
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),
279279
mappings->get_next_hir_id (crate_num),
@@ -311,16 +311,17 @@ ASTLowerQualPathInExpression::visit (AST::QualifiedPathInExpression &expr)
311311
= lower_qual_path_type (expr.get_qualified_path_type ());
312312

313313
std::vector<HIR::PathExprSegment> path_segments;
314-
expr.iterate_path_segments ([&] (AST::PathExprSegment &s) mutable -> bool {
315-
path_segments.push_back (lower_path_expr_seg (s));
316-
317-
// insert the mappings for the segment
318-
HIR::PathExprSegment *lowered_seg = &path_segments.back ();
319-
mappings->insert_hir_path_expr_seg (
320-
lowered_seg->get_mappings ().get_crate_num (),
321-
lowered_seg->get_mappings ().get_hirid (), lowered_seg);
322-
return true;
323-
});
314+
auto &segments = expr.get_segments ();
315+
for (auto &s : segments)
316+
{
317+
path_segments.push_back (lower_path_expr_seg ((s)));
318+
319+
// insert the mappings for the segment
320+
HIR::PathExprSegment *lowered_seg = &path_segments.back ();
321+
mappings->insert_hir_path_expr_seg (
322+
lowered_seg->get_mappings ().get_crate_num (),
323+
lowered_seg->get_mappings ().get_hirid (), lowered_seg);
324+
}
324325

325326
auto crate_num = mappings->get_current_crate ();
326327
Analysis::NodeMapping mapping (crate_num, expr.get_node_id (),

0 commit comments

Comments
 (0)