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