Skip to content

Commit 8c14943

Browse files
committed
Properly handle expression blocks in kind.rs
It was only noticing them in expr_block form, not as function bodies. Closes #1390
1 parent 86279e8 commit 8c14943

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/comp/middle/kind.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ fn check_crate(tcx: ty::ctxt, method_map: typeck::method_map,
4444
let visit = visit::mk_vt(@{
4545
visit_expr: check_expr,
4646
visit_stmt: check_stmt,
47+
visit_block: check_block,
4748
visit_fn: check_fn
4849
with *visit::default_visitor()
4950
});
@@ -117,12 +118,18 @@ fn check_fn_cap_clause(cx: ctx,
117118
}
118119
}
119120

120-
fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
121+
fn check_block(b: blk, cx: ctx, v: visit::vt<ctx>) {
122+
alt b.node.expr {
123+
some(ex) { maybe_copy(cx, ex); }
124+
_ {}
125+
}
126+
visit::visit_block(b, cx, v);
127+
}
121128

129+
fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
122130
alt e.node {
123131
expr_assign(_, ex) | expr_assign_op(_, _, ex) |
124-
expr_block({node: {expr: some(ex), _}, _}) |
125-
expr_unary(box(_), ex) | expr_unary(uniq(_), ex) { maybe_copy(cx, ex); }
132+
expr_unary(box(_), ex) | expr_unary(uniq(_), ex) |
126133
expr_ret(some(ex)) { maybe_copy(cx, ex); }
127134
expr_copy(expr) { check_copy_ex(cx, expr, false); }
128135
// Vector add copies.

0 commit comments

Comments
 (0)