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

18 lines
247 B
Rust
Raw Normal View History

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