diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/closures/once-move-out-on-heap.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/ui/closures/once-move-out-on-heap.rs b/src/test/ui/closures/once-move-out-on-heap.rs new file mode 100644 index 000000000..4e2e400ce --- /dev/null +++ b/src/test/ui/closures/once-move-out-on-heap.rs @@ -0,0 +1,18 @@ +// run-pass +// Testing guarantees provided by once functions. + + + +use std::sync::Arc; + +fn foo<F:FnOnce()>(blk: F) { + blk(); +} + +pub fn main() { + let x = Arc::new(true); + foo(move|| { + assert!(*x); + drop(x); + }); +} |