Skip to content

Commit 3778b6c

Browse files
committed
Prevent copying of uncopyable things via the copy op
1 parent 7550017 commit 3778b6c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/comp/middle/kind.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ fn check_expr(tcx: ty::ctxt, e: @ast::expr) {
177177
ast::expr_swap(a, b) { need_shared_lhs_rhs(tcx, a, b, "<->"); }
178178
ast::expr_copy(a) {
179179
need_expr_kind(tcx, a, ast::kind_shared, "'copy' operand");
180+
check_copy(tcx, a);
180181
}
181182
ast::expr_ret(option::some(a)) {
182183
need_expr_kind(tcx, a, ast::kind_shared, "'ret' operand");
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// error-pattern: mismatched kind
2+
3+
resource r(b: bool) {
4+
}
5+
6+
fn main() {
7+
let i = [r(true)];
8+
let j;
9+
j <- copy [r(true)];
10+
}

0 commit comments

Comments
 (0)