Skip to content

Commit 0953d8f

Browse files
Merge pull request #768 from lcnr/add-nested-asny-test
add deeply-nested-async test
2 parents 7adea5f + 5585610 commit 0953d8f

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-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: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// A regression test for #75992.
2+
// Nested asnyc blocks produce an exponentially sized type tree with a lot of duplicates.
3+
//
4+
// Created by @kellerkindt in https://github.com/rust-lang/rust/issues/75992#issuecomment-682595159.
5+
6+
pub async fn h0(v: &String, x: &u64) { println!("{} {}", v, x) }
7+
pub async fn h1(v: &String, x: &u64) { h0(v, x).await }
8+
pub async fn h2(v: &String, x: &u64) { h1(v, x).await }
9+
pub async fn h3(v: &String, x: &u64) { h2(v, x).await }
10+
pub async fn h4(v: &String, x: &u64) { h3(v, x).await }
11+
pub async fn h5(v: &String, x: &u64) { h4(v, x).await }
12+
pub async fn h6(v: &String, x: &u64) { h5(v, x).await }
13+
pub async fn h7(v: &String, x: &u64) { h6(v, x).await }
14+
pub async fn h8(v: &String, x: &u64) { h7(v, x).await }
15+
pub async fn h9(v: &String, x: &u64) { h8(v, x).await }
16+
17+
pub async fn h10(v: &String, x: &u64) { h9(v, x).await }
18+
pub async fn h11(v: &String, x: &u64) { h10(v, x).await }
19+
pub async fn h12(v: &String, x: &u64) { h11(v, x).await }
20+
pub async fn h13(v: &String, x: &u64) { h12(v, x).await }
21+
pub async fn h14(v: &String, x: &u64) { h13(v, x).await }
22+
pub async fn h15(v: &String, x: &u64) { h14(v, x).await }
23+
pub async fn h16(v: &String, x: &u64) { h15(v, x).await }
24+
pub async fn h17(v: &String, x: &u64) { h16(v, x).await }
25+
pub async fn h18(v: &String, x: &u64) { h17(v, x).await }
26+
pub async fn h19(v: &String, x: &u64) { h18(v, x).await }
27+
28+
29+
macro_rules! async_recursive {
30+
(13, $inner:expr) => { async { async_recursive!(12, $inner) }.await };
31+
(12, $inner:expr) => { async { async_recursive!(11, $inner) }.await };
32+
(11, $inner:expr) => { async { async_recursive!(10, $inner) }.await };
33+
(10, $inner:expr) => { async { async_recursive!(9, $inner) }.await };
34+
35+
(9, $inner:expr) => { async { async_recursive!(8, $inner) }.await };
36+
(8, $inner:expr) => { async { async_recursive!(7, $inner) }.await };
37+
(7, $inner:expr) => { async { async_recursive!(6, $inner) }.await };
38+
(6, $inner:expr) => { async { async_recursive!(5, $inner) }.await };
39+
(5, $inner:expr) => { async { async_recursive!(4, $inner) }.await };
40+
(4, $inner:expr) => { async { async_recursive!(3, $inner) }.await };
41+
(3, $inner:expr) => { async { async_recursive!(2, $inner) }.await };
42+
(2, $inner:expr) => { async { async_recursive!(1, $inner) }.await };
43+
(1, $inner:expr) => { async { async_recursive!(0, $inner) }.await };
44+
(0, $inner:expr) => { async { h19(&String::from("owo"), &0).await; $inner }.await };
45+
}
46+
47+
async fn f() {
48+
async_recursive!(13, println!("hello"));
49+
}
50+
51+
pub fn foo() {
52+
let _ = f();
53+
}

0 commit comments

Comments
 (0)