diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index dbac02c4004..54c39899355 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -96,10 +96,8 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: fn(check_fn)) { if !is_move { check_copy(cx, var_t, sp, is_implicit); } // check that only immutable variables are implicitly copied in - if !is_move { - for fv.each { |fv| - check_imm_free_var(cx, fv.def, fv.span); - } + for fv.each { |fv| + check_imm_free_var(cx, fv.def, fv.span); } } @@ -110,10 +108,8 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: fn(check_fn)) { if !is_move { check_copy(cx, var_t, sp, is_implicit); } // check that only immutable variables are implicitly copied in - if !is_move { - for fv.each { |fv| - check_imm_free_var(cx, fv.def, fv.span); - } + for fv.each { |fv| + check_imm_free_var(cx, fv.def, fv.span); } } @@ -391,8 +387,8 @@ fn check_imm_free_var(cx: ctx, def: def, sp: span) { } def_arg(_, mode) { alt ty::resolved_mode(cx.tcx, mode) { - by_ref | by_val { /* ok */ } - by_mutbl_ref | by_move | by_copy { + by_ref | by_val | by_move | by_copy { /* ok */ } + by_mutbl_ref { cx.tcx.sess.span_err(sp, msg); } } diff --git a/src/test/compile-fail/kindck-implicit-close-over-mut-var.rs b/src/test/compile-fail/kindck-implicit-close-over-mut-var.rs index 11cae9195e7..d646d6db07f 100644 --- a/src/test/compile-fail/kindck-implicit-close-over-mut-var.rs +++ b/src/test/compile-fail/kindck-implicit-close-over-mut-var.rs @@ -1,10 +1,10 @@ fn use(_i: int) {} fn foo() { - // Here, i is *moved* into the closure: OK + // Here, i is *moved* into the closure: Not actually OK let mut i = 0; task::spawn {|| - use(i); + use(i); //! ERROR mutable variables cannot be implicitly captured } } @@ -32,4 +32,4 @@ fn car() { } fn main() { -} \ No newline at end of file +}