]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass-fulldeps/myriad-closures.rs
Auto merge of #61212 - alexcrichton:skip-rustc, r=pietroalbini
[rust.git] / src / test / run-pass-fulldeps / myriad-closures.rs
1 // This test case tests whether we can handle code bases that contain a high
2 // number of closures, something that needs special handling in the MingGW
3 // toolchain.
4 // See https://github.com/rust-lang/rust/issues/34793 for more information.
5
6 // Make sure we don't optimize anything away:
7 // compile-flags: -C no-prepopulate-passes -Cpasses=name-anon-globals
8
9 // Expand something exponentially
10 macro_rules! go_bacterial {
11     ($mac:ident) => ($mac!());
12     ($mac:ident 1 $($t:tt)*) => (
13         go_bacterial!($mac $($t)*);
14         go_bacterial!($mac $($t)*);
15     )
16 }
17
18 macro_rules! mk_closure {
19     () => ((move || {})())
20 }
21
22 macro_rules! mk_fn {
23     () => {
24         {
25             fn function() {
26                 // Make 16 closures
27                 go_bacterial!(mk_closure 1 1 1 1);
28             }
29             let _ = function();
30         }
31     }
32 }
33
34 fn main() {
35     // Make 2^12 functions, each containing 16 closures,
36     // resulting in 2^16 closures overall.
37     go_bacterial!(mk_fn 1 1 1 1  1 1 1 1  1 1 1 1);
38 }