Skip to content

Commit 7550017

Browse files
committed
Prevent copying of uncopyable things via compound assignment ops
1 parent 99cbea5 commit 7550017

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/comp/middle/kind.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ fn check_expr(tcx: ty::ctxt, e: @ast::expr) {
170170
need_shared_lhs_rhs(tcx, a, b, "=");
171171
check_copy(tcx, b);
172172
}
173-
ast::expr_assign_op(_, a, b) { need_shared_lhs_rhs(tcx, a, b, "op="); }
173+
ast::expr_assign_op(_, a, b) {
174+
need_shared_lhs_rhs(tcx, a, b, "op=");
175+
check_copy(tcx, b);
176+
}
174177
ast::expr_swap(a, b) { need_shared_lhs_rhs(tcx, a, b, "<->"); }
175178
ast::expr_copy(a) {
176179
need_expr_kind(tcx, a, ast::kind_shared, "'copy' operand");
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// error-pattern: mismatched kind
2+
3+
resource r(b: bool) {
4+
}
5+
6+
fn main() {
7+
let i = [r(true)];
8+
i += [r(true)];
9+
}

0 commit comments

Comments
 (0)