Prevent copying of uncopyable things via compound assignment ops
This commit is contained in:
parent
99cbea51a1
commit
755001725a
2 changed files with 13 additions and 1 deletions
|
|
@ -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");
|
||||
|
|
|
|||
9
src/test/compile-fail/vec-pinned-nocopy-2.rs
Normal file
9
src/test/compile-fail/vec-pinned-nocopy-2.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// error-pattern: mismatched kind
|
||||
|
||||
resource r(b: bool) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let i = [r(true)];
|
||||
i += [r(true)];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue