Resources are once again not copyable.
This commit is contained in:
parent
9f1a197c2a
commit
8678baab12
2 changed files with 26 additions and 2 deletions
|
|
@ -427,9 +427,9 @@ fn param_bounds_to_kind(bounds: param_bounds) -> kind {
|
|||
for vec::each(*bounds) {|bound|
|
||||
alt bound {
|
||||
bound_copy {
|
||||
kind = lower_kind(kind, kind_copyable());
|
||||
kind = raise_kind(kind, kind_copyable());
|
||||
}
|
||||
bound_send { kind = lower_kind(kind, kind_send_only()); }
|
||||
bound_send { kind = raise_kind(kind, kind_send_only()); }
|
||||
_ {}
|
||||
}
|
||||
}
|
||||
|
|
@ -1284,6 +1284,10 @@ fn kind_send_only() -> kind {
|
|||
kind_(KIND_MASK_SEND)
|
||||
}
|
||||
|
||||
fn kind_top() -> kind {
|
||||
kind_(0xffffffffu32)
|
||||
}
|
||||
|
||||
// Using these query functons is preferable to direct comparison or matching
|
||||
// against the kind constants, as we may modify the kind hierarchy in the
|
||||
// future.
|
||||
|
|
@ -1310,6 +1314,10 @@ fn kind_lteq(a: kind, b: kind) -> bool {
|
|||
}
|
||||
|
||||
fn lower_kind(a: kind, b: kind) -> kind {
|
||||
kind_(*a & *b)
|
||||
}
|
||||
|
||||
fn raise_kind(a: kind, b: kind) -> kind {
|
||||
kind_(*a | *b)
|
||||
}
|
||||
|
||||
|
|
|
|||
16
src/test/compile-fail/pinned-deep-copy.rs
Normal file
16
src/test/compile-fail/pinned-deep-copy.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// error-pattern: copying a noncopyable value
|
||||
|
||||
resource r(i: @mut int) {
|
||||
*i = *i + 1;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let i = @mut 0;
|
||||
{
|
||||
// Can't do this copy
|
||||
let x = ~~~{y: r(i)};
|
||||
let z = x;
|
||||
log(debug, x);
|
||||
}
|
||||
log(error, *i);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue