Skip to content

Commit 223f5be

Browse files
committed
Unique vectors and boxes of pinned are unique kinds. Closes #977
1 parent 8c0918a commit 223f5be

File tree

3 files changed

+3
-15
lines changed

3 files changed

+3
-15
lines changed

src/comp/middle/ty.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -1019,22 +1019,12 @@ fn type_kind(cx: ctxt, ty: t) -> ast::kind {
10191019
ty_box(mt) {
10201020
result = ast::kind_shared;
10211021
}
1022-
// Pointers raise pinned to shared.
1023-
ty_ptr(tm) {
1022+
// Pointers and unique containers raise pinned to shared.
1023+
ty_ptr(tm) | ty_vec(tm) | ty_uniq(tm) {
10241024
let k = type_kind(cx, tm.ty);
10251025
if k == ast::kind_pinned { k = ast::kind_shared; }
10261026
result = kind::lower_kind(result, k);
10271027
}
1028-
// Unique containers pass through their pointee kind.
1029-
//
1030-
// FIXME: These rules do not implement the ~ rules given in
1031-
// the block comment describing the kind system in kind.rs.
1032-
// This code is wrong; it makes ~resource into ~-kind, not
1033-
// @-kind as it should be.
1034-
ty_vec(tm) | ty_uniq(tm) {
1035-
let k = type_kind(cx, tm.ty);
1036-
result = kind::lower_kind(result, k);
1037-
}
10381028
// Records lower to the lowest of their members.
10391029
ty_rec(flds) {
10401030
for f: field in flds {

src/test/compile-fail/unique-pinned-nocopy.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// xfail-test
12
// error-pattern: mismatched kind
23

34
resource r(b: bool) {

src/test/compile-fail/unique-swap2.rs renamed to src/test/run-pass/unique-swap2.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// error-pattern: mismatched kinds
21

32
resource r(i: @mutable int) {
43
*i += 1;
@@ -10,8 +9,6 @@ fn test1() {
109
{
1110
let x = ~r(i);
1211
let y = ~r(j);
13-
// Unique boxes containing resources are lowered to pinned kinds,
14-
// which can't be swapped
1512
x <-> y;
1613
assert ***x == 200;
1714
assert ***y == 100;

0 commit comments

Comments
 (0)