2019-07-26 16:54:25 -05:00
|
|
|
// run-pass
|
2016-07-12 16:39:08 -05: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 14:16:54 -06:00
|
|
|
// Make sure we don't optimize anything away:
|
2018-05-30 15:46:56 -05:00
|
|
|
// compile-flags: -C no-prepopulate-passes -Cpasses=name-anon-globals
|
2016-11-22 14:16:54 -06:00
|
|
|
|
2016-07-12 16:39:08 -05: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 14:16:54 -06:00
|
|
|
() => ((move || {})())
|
2016-07-12 16:39:08 -05: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 11:53:59 -05: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 16:39:08 -05:00
|
|
|
}
|