2019-07-26 21:54:25 +00:00
|
|
|
// run-pass
|
2016-07-12 21:39:08 +00:00
|
|
|
// This test case tests whether we can handle code bases that contain a high
|
|
|
|
// number of closures, something that needs special handling in the MingGW
|
|
|
|
// toolchain.
|
|
|
|
// See https://github.com/rust-lang/rust/issues/34793 for more information.
|
|
|
|
|
2016-11-22 20:16:54 +00:00
|
|
|
// Make sure we don't optimize anything away:
|
2018-05-30 20:46:56 +00:00
|
|
|
// compile-flags: -C no-prepopulate-passes -Cpasses=name-anon-globals
|
2016-11-22 20:16:54 +00:00
|
|
|
|
2016-07-12 21:39:08 +00:00
|
|
|
// Expand something exponentially
|
|
|
|
macro_rules! go_bacterial {
|
|
|
|
($mac:ident) => ($mac!());
|
|
|
|
($mac:ident 1 $($t:tt)*) => (
|
|
|
|
go_bacterial!($mac $($t)*);
|
|
|
|
go_bacterial!($mac $($t)*);
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! mk_closure {
|
2016-11-22 20:16:54 +00:00
|
|
|
() => ((move || {})())
|
2016-07-12 21:39:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! mk_fn {
|
|
|
|
() => {
|
|
|
|
{
|
|
|
|
fn function() {
|
|
|
|
// Make 16 closures
|
|
|
|
go_bacterial!(mk_closure 1 1 1 1);
|
|
|
|
}
|
|
|
|
let _ = function();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2019-06-14 16:53:59 +00:00
|
|
|
// Make 2^8 functions, each containing 16 closures,
|
|
|
|
// resulting in 2^12 closures overall.
|
|
|
|
go_bacterial!(mk_fn 1 1 1 1 1 1 1 1);
|
2016-07-12 21:39:08 +00:00
|
|
|
}
|