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

30 lines
503 B
Rust
Raw Normal View History

2012-08-03 12:22:16 -05:00
// A test case for #2548.
struct foo {
x: @mut int,
2012-08-03 12:22:16 -05:00
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];
2012-09-19 00:44:46 -05:00
v <- ~[mut (move 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;
}