rust/src/test/compile-fail/issue-2548.rs

30 lines
496 B
Rust
Raw Normal View History

2012-08-03 12:22:16 -05:00
// A test case for #2548.
struct foo {
x: @mut int;
drop {
io::println("Goodbye, World!");
*self.x += 1;
}
}
fn foo(x: @mut int) -> foo {
foo { x: x }
}
2012-08-03 12:22:16 -05:00
fn main() {
let x = @mut 0;
{
let mut res = foo(x);
let mut v = ~[mut];
v <- ~[mut res] + v; //~ ERROR instantiating a type parameter with an incompatible type (needs `copy`, got `owned`, missing `copy`)
assert (v.len() == 2);
2012-08-03 12:22:16 -05:00
}
assert *x == 1;
}