]> git.lizzy.rs Git - rust.git/blob - src/test/ui/once-cant-call-twice-on-heap.rs
Add 'src/tools/rust-analyzer/' from commit '977e12a0bdc3e329af179ef3a9d466af9eb613bb'
[rust.git] / src / test / ui / once-cant-call-twice-on-heap.rs
1 // Testing guarantees provided by once functions.
2 // This program would segfault if it were legal.
3
4 use std::sync::Arc;
5
6 fn foo<F:FnOnce()>(blk: F) {
7     blk();
8     blk(); //~ ERROR use of moved value
9 }
10
11 fn main() {
12     let x = Arc::new(true);
13     foo(move|| {
14         assert!(*x);
15         drop(x);
16     });
17 }