Unique vectors and boxes of pinned are unique kinds. Closes #977
This commit is contained in:
parent
8c0918ac18
commit
223f5be166
|
@ -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 {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// xfail-test
|
||||
// error-pattern: mismatched kind
|
||||
|
||||
resource r(b: bool) {
|
||||
|
|
|
@ -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;
|
Loading…
Reference in New Issue