提交 8678baab 编写于 作者: E Eric Holk

Resources are once again not copyable.

上级 9f1a197c
...@@ -427,9 +427,9 @@ fn param_bounds_to_kind(bounds: param_bounds) -> kind { ...@@ -427,9 +427,9 @@ fn param_bounds_to_kind(bounds: param_bounds) -> kind {
for vec::each(*bounds) {|bound| for vec::each(*bounds) {|bound|
alt bound { alt bound {
bound_copy { 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 { ...@@ -1284,6 +1284,10 @@ fn kind_send_only() -> kind {
kind_(KIND_MASK_SEND) kind_(KIND_MASK_SEND)
} }
fn kind_top() -> kind {
kind_(0xffffffffu32)
}
// Using these query functons is preferable to direct comparison or matching // Using these query functons is preferable to direct comparison or matching
// against the kind constants, as we may modify the kind hierarchy in the // against the kind constants, as we may modify the kind hierarchy in the
// future. // future.
...@@ -1310,6 +1314,10 @@ fn kind_lteq(a: kind, b: kind) -> bool { ...@@ -1310,6 +1314,10 @@ fn kind_lteq(a: kind, b: kind) -> bool {
} }
fn lower_kind(a: kind, b: kind) -> kind { fn lower_kind(a: kind, b: kind) -> kind {
kind_(*a & *b)
}
fn raise_kind(a: kind, b: kind) -> kind {
kind_(*a | *b) kind_(*a | *b)
} }
......
// 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);
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册