rust/src/test/ui/once-cant-call-twice-on-heap.rs
2018-12-25 21:08:33 -07:00

19 lines
331 B
Rust

// Testing guarantees provided by once functions.
// This program would segfault if it were legal.
#![feature(once_fns)]
use std::sync::Arc;
fn foo<F:FnOnce()>(blk: F) {
blk();
blk(); //~ ERROR use of moved value
}
fn main() {
let x = Arc::new(true);
foo(move|| {
assert!(*x);
drop(x);
});
}