Skip to content

Commit 8678baa

Browse files
committed
Resources are once again not copyable.
1 parent 9f1a197 commit 8678baa

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/rustc/middle/ty.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,9 @@ fn param_bounds_to_kind(bounds: param_bounds) -> kind {
427427
for vec::each(*bounds) {|bound|
428428
alt bound {
429429
bound_copy {
430-
kind = lower_kind(kind, kind_copyable());
430+
kind = raise_kind(kind, kind_copyable());
431431
}
432-
bound_send { kind = lower_kind(kind, kind_send_only()); }
432+
bound_send { kind = raise_kind(kind, kind_send_only()); }
433433
_ {}
434434
}
435435
}
@@ -1284,6 +1284,10 @@ fn kind_send_only() -> kind {
12841284
kind_(KIND_MASK_SEND)
12851285
}
12861286

1287+
fn kind_top() -> kind {
1288+
kind_(0xffffffffu32)
1289+
}
1290+
12871291
// Using these query functons is preferable to direct comparison or matching
12881292
// against the kind constants, as we may modify the kind hierarchy in the
12891293
// future.
@@ -1310,6 +1314,10 @@ fn kind_lteq(a: kind, b: kind) -> bool {
13101314
}
13111315

13121316
fn lower_kind(a: kind, b: kind) -> kind {
1317+
kind_(*a & *b)
1318+
}
1319+
1320+
fn raise_kind(a: kind, b: kind) -> kind {
13131321
kind_(*a | *b)
13141322
}
13151323

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// error-pattern: copying a noncopyable value
2+
3+
resource r(i: @mut int) {
4+
*i = *i + 1;
5+
}
6+
7+
fn main() {
8+
let i = @mut 0;
9+
{
10+
// Can't do this copy
11+
let x = ~~~{y: r(i)};
12+
let z = x;
13+
log(debug, x);
14+
}
15+
log(error, *i);
16+
}

0 commit comments

Comments
 (0)