mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
parent
61a14f3df0
commit
d174d917e2
@ -1019,13 +1019,9 @@ fn type_kind(cx: ctxt, ty: t) -> ast::kind {
|
||||
ty_box(mt) {
|
||||
result = ast::kind_shared;
|
||||
}
|
||||
ty_uniq(mt) {
|
||||
// FIXME (409): Calculate kind
|
||||
result = ast::kind_unique;
|
||||
}
|
||||
// Pointers and unique boxes / vecs raise pinned to shared,
|
||||
// otherwise pass through their pointee kind.
|
||||
ty_ptr(tm) | ty_vec(tm) {
|
||||
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);
|
||||
|
9
src/test/compile-fail/unique-unique-kind.rs
Normal file
9
src/test/compile-fail/unique-unique-kind.rs
Normal file
@ -0,0 +1,9 @@
|
||||
// error-pattern: needed unique type
|
||||
|
||||
fn f<~T>(i: T) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let i = ~@100;
|
||||
f(i);
|
||||
}
|
59
src/test/run-pass/unique-kinds.rs
Normal file
59
src/test/run-pass/unique-kinds.rs
Normal file
@ -0,0 +1,59 @@
|
||||
fn unique() {
|
||||
|
||||
fn f<~T>(i: T, j: T) {
|
||||
assert i == j;
|
||||
}
|
||||
|
||||
fn g<~T>(i: T, j: T) {
|
||||
assert i != j;
|
||||
}
|
||||
|
||||
let i = ~100;
|
||||
let j = ~100;
|
||||
f(i, j);
|
||||
let i = ~100;
|
||||
let j = ~101;
|
||||
g(i, j);
|
||||
}
|
||||
|
||||
fn shared() {
|
||||
|
||||
fn f<@T>(i: T, j: T) {
|
||||
assert i == j;
|
||||
}
|
||||
|
||||
fn g<@T>(i: T, j: T) {
|
||||
assert i != j;
|
||||
}
|
||||
|
||||
let i = ~100;
|
||||
let j = ~100;
|
||||
f(i, j);
|
||||
let i = ~100;
|
||||
let j = ~101;
|
||||
g(i, j);
|
||||
}
|
||||
|
||||
fn pinned() {
|
||||
|
||||
fn f<T>(i: T, j: T) {
|
||||
assert i == j;
|
||||
}
|
||||
|
||||
fn g<T>(i: T, j: T) {
|
||||
assert i != j;
|
||||
}
|
||||
|
||||
let i = ~100;
|
||||
let j = ~100;
|
||||
f(i, j);
|
||||
let i = ~100;
|
||||
let j = ~101;
|
||||
g(i, j);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
unique();
|
||||
shared();
|
||||
pinned();
|
||||
}
|
Loading…
Reference in New Issue
Block a user