diff options
| author | Ben Blum <bblum@andrew.cmu.edu> | 2012-08-24 15:24:04 -0400 |
|---|---|---|
| committer | Ben Blum <bblum@andrew.cmu.edu> | 2012-08-24 16:43:03 -0400 |
| commit | 37bcd67a0956e0d3264abef08027f9d70d3b362e (patch) | |
| tree | 3ead4016ef0104c02ec9f2f42df99457ea7217b3 /src/rustc | |
| parent | e47d2f60607142eaf68a0c560f5c3d37fd1da13d (diff) | |
| download | rust-37bcd67a0956e0d3264abef08027f9d70d3b362e.tar.gz rust-37bcd67a0956e0d3264abef08027f9d70d3b362e.zip | |
Enforce copyability in bind_by_value match arms (fix #3255)
Diffstat (limited to 'src/rustc')
| -rw-r--r-- | src/rustc/middle/kind.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index 87b4ac140b6..76c2b08a833 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -74,6 +74,7 @@ fn check_crate(tcx: ty::ctxt, last_use_map: last_use_map, current_item: -1}; let visit = visit::mk_vt(@{ + visit_arm: check_arm, visit_expr: check_expr, visit_stmt: check_stmt, visit_block: check_block, @@ -225,6 +226,19 @@ fn check_block(b: blk, cx: ctx, v: visit::vt<ctx>) { visit::visit_block(b, cx, v); } +fn check_arm(a: arm, cx: ctx, v: visit::vt<ctx>) { + for vec::each(a.pats) |p| { + do pat_util::pat_bindings(cx.tcx.def_map, p) |mode, id, span, _path| { + if mode == bind_by_value { + let t = ty::node_id_to_type(cx.tcx, id); + let reason = "consider binding with `ref` or `move` instead"; + check_copy(cx, id, t, span, false, some((reason,reason))); + } + } + } + visit::visit_arm(a, cx, v); +} + fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { debug!("kind::check_expr(%s)", expr_to_str(e, cx.tcx.sess.intr())); |
