]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-6801.rs
Rollup merge of #60492 - acrrd:issues/54054_chain, r=SimonSapin
[rust.git] / src / test / ui / issues / issue-6801.rs
1 // Creating a stack closure which references a box and then
2 // transferring ownership of the box before invoking the stack
3 // closure results in a crash.
4
5 #![feature(box_syntax)]
6
7 fn twice(x: Box<usize>) -> usize {
8      *x * 2
9 }
10
11 fn invoke<F>(f: F) where F: FnOnce() -> usize {
12      f();
13 }
14
15 fn main() {
16       let x  : Box<usize>  = box 9;
17       let sq =  || { *x * *x };
18
19       twice(x); //~ ERROR: cannot move out of
20       invoke(sq);
21 }