Prevent copying of uncopyable things via the copy op

This commit is contained in:
Brian Anderson 2011-09-26 20:03:14 -07:00
parent 755001725a
commit 3778b6c6a8
2 changed files with 11 additions and 0 deletions

View File

@ -177,6 +177,7 @@ fn check_expr(tcx: ty::ctxt, e: @ast::expr) {
ast::expr_swap(a, b) { need_shared_lhs_rhs(tcx, a, b, "<->"); }
ast::expr_copy(a) {
need_expr_kind(tcx, a, ast::kind_shared, "'copy' operand");
check_copy(tcx, a);
}
ast::expr_ret(option::some(a)) {
need_expr_kind(tcx, a, ast::kind_shared, "'ret' operand");

View File

@ -0,0 +1,10 @@
// error-pattern: mismatched kind
resource r(b: bool) {
}
fn main() {
let i = [r(true)];
let j;
j <- copy [r(true)];
}