parent
97629727b1
commit
e5d5682065
@ -1021,11 +1021,18 @@ fn type_kind(cx: ctxt, ty: t) -> ast::kind {
|
||||
}
|
||||
// Pointers and unique boxes / vecs raise pinned to shared,
|
||||
// otherwise pass through their pointee kind.
|
||||
ty_ptr(tm) | ty_vec(tm) | ty_uniq(tm) {
|
||||
ty_ptr(tm) | ty_vec(tm) {
|
||||
let k = type_kind(cx, tm.ty);
|
||||
if k == ast::kind_pinned { k = ast::kind_shared; }
|
||||
result = kind::lower_kind(result, k);
|
||||
}
|
||||
// Unique boxes pass through their pointee kind. FIXME: Shouldn't
|
||||
// pointers and vecs do this too to avoid copying vectors of pinned
|
||||
// things?
|
||||
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 {
|
||||
|
10
src/test/compile-fail/unique-pinned-nocopy.rs
Normal file
10
src/test/compile-fail/unique-pinned-nocopy.rs
Normal file
@ -0,0 +1,10 @@
|
||||
// error-pattern: mismatched kind
|
||||
|
||||
resource r(b: bool) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let i = ~r(true);
|
||||
let j;
|
||||
j = i;
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
|
||||
|
||||
type recbox<T> = {x: ~T};
|
||||
|
||||
fn reclift<T>(t: T) -> recbox<T> { ret {x: ~t}; }
|
||||
fn reclift<@T>(t: T) -> recbox<T> { ret {x: ~t}; }
|
||||
|
||||
fn main() {
|
||||
let foo: int = 17;
|
||||
|
@ -1,3 +1,9 @@
|
||||
// xfail-test
|
||||
|
||||
// This no longer works because ~r() is lowered to a pinned type
|
||||
// (which can't be swapped). Should probably be a compile-fail
|
||||
// test.
|
||||
|
||||
resource r(i: @mutable int) {
|
||||
*i += 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user