diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index ddb3c2054b69..b3701bd74f42 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -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) } diff --git a/src/test/compile-fail/pinned-deep-copy.rs b/src/test/compile-fail/pinned-deep-copy.rs new file mode 100644 index 000000000000..1a07b3f1de0e --- /dev/null +++ b/src/test/compile-fail/pinned-deep-copy.rs @@ -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); +} \ No newline at end of file