Prevent copying of uncopyable things via compound assignment ops

This commit is contained in:
Brian Anderson 2011-09-26 19:59:49 -07:00
parent 99cbea51a1
commit 755001725a
2 changed files with 13 additions and 1 deletions

View file

@ -170,7 +170,10 @@ fn check_expr(tcx: ty::ctxt, e: @ast::expr) {
need_shared_lhs_rhs(tcx, a, b, "=");
check_copy(tcx, b);
}
ast::expr_assign_op(_, a, b) { need_shared_lhs_rhs(tcx, a, b, "op="); }
ast::expr_assign_op(_, a, b) {
need_shared_lhs_rhs(tcx, a, b, "op=");
check_copy(tcx, b);
}
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");

View file

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