From 223f5be166b8a49b1ed620dafc882200c552d779 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 26 Sep 2011 13:38:12 -0700 Subject: [PATCH] Unique vectors and boxes of pinned are unique kinds. Closes #977 --- src/comp/middle/ty.rs | 14 ++------------ src/test/compile-fail/unique-pinned-nocopy.rs | 1 + .../{compile-fail => run-pass}/unique-swap2.rs | 3 --- 3 files changed, 3 insertions(+), 15 deletions(-) rename src/test/{compile-fail => run-pass}/unique-swap2.rs (76%) diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index c274191aff4e..5dda7e74a99e 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -1019,22 +1019,12 @@ fn type_kind(cx: ctxt, ty: t) -> ast::kind { ty_box(mt) { result = ast::kind_shared; } - // Pointers raise pinned to shared. - ty_ptr(tm) { + // Pointers and unique containers raise pinned to shared. + ty_ptr(tm) | ty_vec(tm) | ty_uniq(tm) { let k = type_kind(cx, tm.ty); if k == ast::kind_pinned { k = ast::kind_shared; } result = kind::lower_kind(result, k); } - // Unique containers pass through their pointee kind. - // - // FIXME: These rules do not implement the ~ rules given in - // the block comment describing the kind system in kind.rs. - // This code is wrong; it makes ~resource into ~-kind, not - // @-kind as it should be. - ty_vec(tm) | ty_uniq(tm) { - let k = type_kind(cx, tm.ty); - result = kind::lower_kind(result, k); - } // Records lower to the lowest of their members. ty_rec(flds) { for f: field in flds { diff --git a/src/test/compile-fail/unique-pinned-nocopy.rs b/src/test/compile-fail/unique-pinned-nocopy.rs index 9c1cad78b032..0f0f0d3bf9b7 100644 --- a/src/test/compile-fail/unique-pinned-nocopy.rs +++ b/src/test/compile-fail/unique-pinned-nocopy.rs @@ -1,3 +1,4 @@ +// xfail-test // error-pattern: mismatched kind resource r(b: bool) { diff --git a/src/test/compile-fail/unique-swap2.rs b/src/test/run-pass/unique-swap2.rs similarity index 76% rename from src/test/compile-fail/unique-swap2.rs rename to src/test/run-pass/unique-swap2.rs index f1cfebf1274c..f15d0aecac51 100644 --- a/src/test/compile-fail/unique-swap2.rs +++ b/src/test/run-pass/unique-swap2.rs @@ -1,4 +1,3 @@ -// error-pattern: mismatched kinds resource r(i: @mutable int) { *i += 1; @@ -10,8 +9,6 @@ fn test1() { { let x = ~r(i); let y = ~r(j); - // Unique boxes containing resources are lowered to pinned kinds, - // which can't be swapped x <-> y; assert ***x == 200; assert ***y == 100;