aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/hir
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-10-13 11:34:46 +0000
committerGitHub <noreply@github.com>2021-10-13 11:34:46 +0000
commit3057d98a4e3fc777b06e51cd678723f5c5b4c898 (patch)
treecce411c133aa2df69d7083d4cf68edeb144bc9f5 /gcc/rust/hir
parent7a341772dcf51445af08071eeb0ed0ea93cd60a1 (diff)
parent61db846ac9773bb2c5aecbab1ba10282869e3e9f (diff)
downloadgcc-3057d98a4e3fc777b06e51cd678723f5c5b4c898.zip
gcc-3057d98a4e3fc777b06e51cd678723f5c5b4c898.tar.gz
gcc-3057d98a4e3fc777b06e51cd678723f5c5b4c898.tar.bz2
Merge #728
728: Remove `AST::BlockExpr` lambda and add `get_statements` r=philberty a=wan-nyan-wan This PR Fixes #724. This patch removes lambda iterators in `AST::BlockExpr` and replace these with `get_statements`. These lambda iterators need to be removed they make working with the IR's more complex for static analysis. Co-authored-by: wan-nyan-wan <distributed.system.love@gmail.com>
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r--gcc/rust/hir/rust-ast-lower.cc21
1 files changed, 11 insertions, 10 deletions
diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc
index ed0774c..3a675b7 100644
--- a/gcc/rust/hir/rust-ast-lower.cc
+++ b/gcc/rust/hir/rust-ast-lower.cc
@@ -64,16 +64,17 @@ ASTLoweringBlock::visit (AST::BlockExpr &expr)
{
std::vector<std::unique_ptr<HIR::Stmt> > block_stmts;
bool block_did_terminate = false;
- expr.iterate_stmts ([&] (AST::Stmt *s) mutable -> bool {
- if (block_did_terminate)
- rust_warning_at (s->get_locus (), 0, "unreachable statement");
-
- bool terminated = false;
- auto translated_stmt = ASTLoweringStmt::translate (s, &terminated);
- block_stmts.push_back (std::unique_ptr<HIR::Stmt> (translated_stmt));
- block_did_terminate |= terminated;
- return true;
- });
+
+ for (auto &s : expr.get_statements ())
+ {
+ if (block_did_terminate)
+ rust_warning_at (s->get_locus (), 0, "unreachable statement");
+
+ bool terminated = false;
+ auto translated_stmt = ASTLoweringStmt::translate (s.get (), &terminated);
+ block_stmts.push_back (std::unique_ptr<HIR::Stmt> (translated_stmt));
+ block_did_terminate |= terminated;
+ }
if (expr.has_tail_expr () && block_did_terminate)
{