@@ -71,20 +71,11 @@ ASTLoweringBlock::visit (AST::BlockExpr &expr)
71
71
std::vector<std::unique_ptr<HIR::Stmt> > block_stmts;
72
72
bool block_did_terminate = false ;
73
73
expr.iterate_stmts ([&] (AST::Stmt *s) mutable -> bool {
74
- auto translated_stmt = ASTLoweringStmt::translate (s, &block_did_terminate);
75
- block_stmts.push_back (std::unique_ptr<HIR::Stmt> (translated_stmt));
76
- return !block_did_terminate;
77
- });
78
-
79
- // if there was a return expression everything after that becomes
80
- // unreachable code. This can be detected for any AST NodeIDs that have no
81
- // associated HIR Mappings
82
- expr.iterate_stmts ([&] (AST::Stmt *s) -> bool {
83
- HirId ref;
84
- if (!mappings->lookup_node_to_hir (mappings->get_current_crate (),
85
- s->get_node_id (), &ref))
74
+ if (block_did_terminate)
86
75
rust_warning_at (s->get_locus_slow (), 0 , " unreachable statement" );
87
76
77
+ auto translated_stmt = ASTLoweringStmt::translate (s, &block_did_terminate);
78
+ block_stmts.push_back (std::unique_ptr<HIR::Stmt> (translated_stmt));
88
79
return true ;
89
80
});
90
81
@@ -96,7 +87,7 @@ ASTLoweringBlock::visit (AST::BlockExpr &expr)
96
87
}
97
88
98
89
HIR::ExprWithoutBlock *tail_expr = nullptr ;
99
- if (expr.has_tail_expr () && !block_did_terminate )
90
+ if (expr.has_tail_expr ())
100
91
{
101
92
tail_expr = (HIR::ExprWithoutBlock *) ASTLoweringExpr::translate (
102
93
expr.get_tail_expr ().get (), &block_did_terminate);
0 commit comments