Prevent copying of uncopyable things via the copy op
This commit is contained in:
parent
755001725a
commit
3778b6c6a8
@ -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");
|
||||
|
10
src/test/compile-fail/vec-pinned-nocopy-3.rs
Normal file
10
src/test/compile-fail/vec-pinned-nocopy-3.rs
Normal 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)];
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user