]> git.lizzy.rs Git - rust.git/blob - tests/run-pass/closures.rs
use compiletest_rs
[rust.git] / tests / run-pass / closures.rs
1 #![feature(custom_attribute)]
2 #![allow(dead_code, unused_attributes)]
3
4 #[miri_run]
5 fn simple() -> i32 {
6     let y = 10;
7     let f = |x| x + y;
8     f(2)
9 }
10
11 #[miri_run]
12 fn crazy_closure() -> (i32, i32, i32) {
13     fn inner<T: Copy>(t: T) -> (i32, T, T) {
14         struct NonCopy;
15         let x = NonCopy;
16
17         let a = 2;
18         let b = 40;
19         let f = move |y, z, asdf| {
20             drop(x);
21             (a + b + y + z, asdf, t)
22         };
23         f(a, b, t)
24     }
25
26     inner(10)
27 }
28
29 // #[miri_run]
30 // fn closure_arg_adjustment_problem() -> i64 {
31 //     fn once<F: FnOnce(i64)>(f: F) { f(2); }
32 //     let mut y = 1;
33 //     {
34 //         let f = |x| y += x;
35 //         once(f);
36 //     }
37 //     y
38 // }
39
40 fn main() {}