mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 19:58:32 +00:00
parent
196b2b920f
commit
a7573af59d
@ -1,20 +0,0 @@
|
|||||||
// xfail-test
|
|
||||||
// error-pattern:mismatched kinds for tag parameter
|
|
||||||
resource r(i: @mutable int) {
|
|
||||||
*i = *i + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
tag t {
|
|
||||||
t0(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let i = @mutable 0;
|
|
||||||
{
|
|
||||||
let j <- r(i);
|
|
||||||
// No no no no no
|
|
||||||
let k <- t0(j);
|
|
||||||
}
|
|
||||||
log_err *i;
|
|
||||||
assert *i == 2;
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
// xfail-test
|
|
||||||
// error-pattern:mismatched kind
|
|
||||||
|
|
||||||
resource r(i: @mutable int) {
|
|
||||||
*i = *i + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let a = @mutable 0;
|
|
||||||
{
|
|
||||||
let i <- r(a);
|
|
||||||
// Can't copy into here
|
|
||||||
let j <- [i];
|
|
||||||
}
|
|
||||||
log_err *a;
|
|
||||||
// this is no good
|
|
||||||
assert *a == 2;
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
// xfail-test
|
|
||||||
// error-pattern:mismatched kind
|
|
||||||
|
|
||||||
resource r(i: @mutable int) {
|
|
||||||
*i = *i + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let a = @mutable 0;
|
|
||||||
{
|
|
||||||
let i <- ~r(a);
|
|
||||||
// Can't copy into here
|
|
||||||
let j <- [i];
|
|
||||||
}
|
|
||||||
log_err *a;
|
|
||||||
// this is no good
|
|
||||||
assert *a == 2;
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
// Resources can't be copied into other types but still need to be able
|
// Resources can't be copied, but storing into data structures counts
|
||||||
// to find their way into things.
|
// as a move unless the stored thing is used afterwards.
|
||||||
|
|
||||||
resource r(i: @mutable int) {
|
resource r(i: @mutable int) {
|
||||||
*i = *i + 1;
|
*i = *i + 1;
|
||||||
@ -59,6 +59,14 @@ fn test_box_rec() {
|
|||||||
assert *i == 1;
|
assert *i == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_obj() {
|
||||||
|
obj o(_f: r) {}
|
||||||
|
let i = @mutable 0;
|
||||||
|
let rr = r(i);
|
||||||
|
{ let _oo = o(rr); }
|
||||||
|
assert *i == 1;
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
test_box();
|
test_box();
|
||||||
test_rec();
|
test_rec();
|
||||||
@ -67,4 +75,5 @@ fn main() {
|
|||||||
test_tup();
|
test_tup();
|
||||||
test_unique();
|
test_unique();
|
||||||
test_box_rec();
|
test_box_rec();
|
||||||
|
test_obj();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
resource r(i: int) {
|
resource r(i: @mutable int) { *i += 1; }
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Even though this looks like a copy, it's guaranteed not to be
|
let i = @mutable 0;
|
||||||
let a = r(0);
|
// Even though these look like copies, they are guaranteed not to be
|
||||||
|
{
|
||||||
|
let a = r(i);
|
||||||
|
let b = (a, 10);
|
||||||
|
let (c, _d) = b;
|
||||||
|
log c;
|
||||||
|
}
|
||||||
|
assert *i == 1;
|
||||||
}
|
}
|
@ -5,21 +5,19 @@ fn u_foo<send T>(unique: T) { }
|
|||||||
resource r(i: int) { }
|
resource r(i: int) { }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// FIXME: passing resources doesn't work?
|
p_foo(r(10));
|
||||||
//p_foo(r(10));
|
p_foo(@r(10));
|
||||||
//p_foo(@r(10));
|
|
||||||
// FIXME: unique boxes not yet supported.
|
p_foo(~r(10));
|
||||||
// p_foo(~r(10));
|
|
||||||
p_foo(@10);
|
p_foo(@10);
|
||||||
// p_foo(~10);
|
p_foo(~10);
|
||||||
p_foo(10);
|
p_foo(10);
|
||||||
|
|
||||||
//s_foo(@r(10));
|
s_foo(@r(10));
|
||||||
//s_foo(~r(10));
|
|
||||||
s_foo(@10);
|
s_foo(@10);
|
||||||
//s_foo(~10);
|
s_foo(~10);
|
||||||
s_foo(10);
|
s_foo(10);
|
||||||
|
|
||||||
//u_foo(~10);
|
u_foo(~10);
|
||||||
u_foo(10);
|
u_foo(10);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user