]> git.lizzy.rs Git - rust.git/blob - src/test/ui/once-cant-call-twice-on-heap.rs
Auto merge of #81507 - weiznich:add_diesel_to_cargo_test, r=Mark-Simulacrum
[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 #![feature(once_fns)]
5 use std::sync::Arc;
6
7 fn foo<F:FnOnce()>(blk: F) {
8     blk();
9     blk(); //~ ERROR use of moved value
10 }
11
12 fn main() {
13     let x = Arc::new(true);
14     foo(move|| {
15         assert!(*x);
16         drop(x);
17     });
18 }