]> git.lizzy.rs Git - rust.git/blob - tests/ui/once-cant-call-twice-on-heap.rs
Rollup merge of #106715 - BoxyUwU:new_solver_triagebot, r=lcnr
[rust.git] / tests / 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 }