diff options
| author | Arpad Borsos <swatinem@swatinem.de> | 2023-02-05 17:32:52 +0100 |
|---|---|---|
| committer | Arpad Borsos <swatinem@swatinem.de> | 2023-02-07 08:52:15 +0100 |
| commit | 7a7b2e352108e17dc4ac834b02ff59e7f81a2c5d (patch) | |
| tree | 38b5faf44581a74f169d277c637455a7d0449097 /tests/ui/async-await/future-sizes/async-awaiting-fut.rs | |
| parent | dffea43fc1102bdfe16d88ed412c23d4f0f08d9d (diff) | |
| download | rust-7a7b2e352108e17dc4ac834b02ff59e7f81a2c5d.tar.gz rust-7a7b2e352108e17dc4ac834b02ff59e7f81a2c5d.zip | |
Add test for Future inflating arg size to 3x
This adds one more test that should track improvements to generator layout, like #62958 and #62575. In particular, this test highlights suboptimal layout, as the storage for the argument future is not being reused across its usage as `upvar`, `local` and `awaitee` (being polled to completion).
Diffstat (limited to 'tests/ui/async-await/future-sizes/async-awaiting-fut.rs')
| -rw-r--r-- | tests/ui/async-await/future-sizes/async-awaiting-fut.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/ui/async-await/future-sizes/async-awaiting-fut.rs b/tests/ui/async-await/future-sizes/async-awaiting-fut.rs new file mode 100644 index 00000000000..1816d842d6c --- /dev/null +++ b/tests/ui/async-await/future-sizes/async-awaiting-fut.rs @@ -0,0 +1,24 @@ +// compile-flags: -Z print-type-sizes --crate-type lib +// edition:2021 +// build-pass +// ignore-pass + +async fn wait() {} + +async fn big_fut(arg: [u8; 1024]) {} + +async fn calls_fut(fut: impl std::future::Future<Output = ()>) { + loop { + wait().await; + if true { + return fut.await; + } else { + wait().await; + } + } +} + +pub async fn test() { + let fut = big_fut([0u8; 1024]); + calls_fut(fut).await; +} |
