rust/src/test/compile-fail/noncopyable-class.rs

29 lines
372 B
Rust
Raw Normal View History

// error-pattern: copying a noncopyable value
// Test that a class with a non-copyable field can't be
// copied
2012-08-15 20:46:55 -05:00
struct bar {
2012-09-06 21:40:15 -05:00
x: int,
drop {}
}
2012-09-05 17:58:43 -05:00
fn bar(x:int) -> bar {
bar {
x: x
}
}
2012-08-15 20:46:55 -05:00
struct foo {
2012-09-06 21:40:15 -05:00
i: int,
j: bar,
2012-09-05 17:58:43 -05:00
}
fn foo(i:int) -> foo {
foo {
i: i,
j: bar(5)
}
}
fn main() { let x <- foo(10); let y = x; log(error, x); }