rust/src/test/compile-fail/kindck-owned.rs

20 lines
486 B
Rust
Raw Normal View History

fn copy1<T: copy>(t: T) -> fn@() -> T {
fn@() -> T { t } //~ ERROR value may contain borrowed pointers
}
fn copy2<T: copy owned>(t: T) -> fn@() -> T {
fn@() -> T { t }
}
fn main() {
let x = &3;
copy2(&x); //~ ERROR missing `owned`
copy2(@3);
copy2(@&x); //~ ERROR missing `owned`
copy2(fn@() {});
copy2(fn~() {}); //~ WARNING instantiating copy type parameter with a not implicitly copyable type
copy2(fn&() {}); //~ ERROR missing `copy owned`
}