rust/src/test/compile-fail/use-after-move-self.rs

19 lines
240 B
Rust
Raw Normal View History

struct S {
x: ~int
}
impl S {
fn foo(self) -> int {
self.bar();
return *self.x; //~ ERROR use of moved value
}
fn bar(self) {}
}
fn main() {
let x = S { x: ~1 };
io::println(x.foo().to_str());
}