Skip to content

Commit dbf7aa9

Browse files
committed
add deeply-nested-async test
1 parent f7df7bc commit dbf7aa9

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

collector/benchmarks/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ programs.
7575
- **ctfe-stress-4**: A stress test for compile-time function evaluation.
7676
- **deeply-nested**: A small program that caused [exponential
7777
behavior](https://github.com/rust-lang/rust/issues/38528) in the past.
78+
- **deeply-nested-async**: Another small program that caused [exponential
79+
behavior](https://github.com/rust-lang/rust/issues/75992) in the past.
80+
- **deeply-nested-closures**: A small program that caused [exponential
81+
behavior](https://github.com/rust-lang/rust/issues/72408) in the past.
7882
- **deep-vector**: A test containing a single large vector of zeroes, which
7983
caused [poor performance](https://github.com/rust-lang/rust/issues/20936) in
8084
the past.

collector/benchmarks/deeply-nested-async/Cargo.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "deeply-nested-async"
3+
version = "0.1.0"
4+
authors = ["Bastian Kauschke <[email protected]>"]
5+
edition = "2018"
6+
7+
[dependencies]
8+
9+
[workspace]
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// A regression test for #75992.
2+
// Nested asnyc blocks produce an exponentially sized type tree with a lot of duplicates.
3+
4+
pub async fn h0(v: &String, x: &u64) { println!("{} {}", v, x) }
5+
pub async fn h1(v: &String, x: &u64) { h0(v, x).await }
6+
pub async fn h2(v: &String, x: &u64) { h1(v, x).await }
7+
pub async fn h3(v: &String, x: &u64) { h2(v, x).await }
8+
pub async fn h4(v: &String, x: &u64) { h3(v, x).await }
9+
pub async fn h5(v: &String, x: &u64) { h4(v, x).await }
10+
pub async fn h6(v: &String, x: &u64) { h5(v, x).await }
11+
pub async fn h7(v: &String, x: &u64) { h6(v, x).await }
12+
pub async fn h8(v: &String, x: &u64) { h7(v, x).await }
13+
pub async fn h9(v: &String, x: &u64) { h8(v, x).await }
14+
15+
pub async fn h10(v: &String, x: &u64) { h9(v, x).await }
16+
pub async fn h11(v: &String, x: &u64) { h10(v, x).await }
17+
pub async fn h12(v: &String, x: &u64) { h11(v, x).await }
18+
pub async fn h13(v: &String, x: &u64) { h12(v, x).await }
19+
pub async fn h14(v: &String, x: &u64) { h13(v, x).await }
20+
pub async fn h15(v: &String, x: &u64) { h14(v, x).await }
21+
pub async fn h16(v: &String, x: &u64) { h15(v, x).await }
22+
pub async fn h17(v: &String, x: &u64) { h16(v, x).await }
23+
pub async fn h18(v: &String, x: &u64) { h17(v, x).await }
24+
pub async fn h19(v: &String, x: &u64) { h18(v, x).await }
25+
26+
27+
macro_rules! async_recursive {
28+
(13, $inner:expr) => { async { async_recursive!(12, $inner) }.await };
29+
(12, $inner:expr) => { async { async_recursive!(11, $inner) }.await };
30+
(11, $inner:expr) => { async { async_recursive!(10, $inner) }.await };
31+
(10, $inner:expr) => { async { async_recursive!(9, $inner) }.await };
32+
33+
(9, $inner:expr) => { async { async_recursive!(8, $inner) }.await };
34+
(8, $inner:expr) => { async { async_recursive!(7, $inner) }.await };
35+
(7, $inner:expr) => { async { async_recursive!(6, $inner) }.await };
36+
(6, $inner:expr) => { async { async_recursive!(5, $inner) }.await };
37+
(5, $inner:expr) => { async { async_recursive!(4, $inner) }.await };
38+
(4, $inner:expr) => { async { async_recursive!(3, $inner) }.await };
39+
(3, $inner:expr) => { async { async_recursive!(2, $inner) }.await };
40+
(2, $inner:expr) => { async { async_recursive!(1, $inner) }.await };
41+
(1, $inner:expr) => { async { async_recursive!(0, $inner) }.await };
42+
(0, $inner:expr) => { async { h19(&String::from("owo"), &0).await; $inner }.await };
43+
}
44+
45+
async fn f() {
46+
async_recursive!(13, println!("hello"));
47+
}
48+
49+
pub fn foo() {
50+
let _ = f();
51+
}

0 commit comments

Comments
 (0)