Rollup merge of #107500 - bryangarza:future-sizes-baseline-test, r=compiler-errors
Add tests to assert current behavior of large future sizes Based on a couple of sources: - https://swatinem.de/blog/future-size/ - https://github.com/rust-lang/rust/issues/62958
This commit is contained in:
commit
22aa680c44
3 changed files with 94 additions and 0 deletions
16
tests/ui/async-await/future-sizes/future-as-arg.rs
Normal file
16
tests/ui/async-await/future-sizes/future-as-arg.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
// edition: 2021
|
||||
// run-pass
|
||||
|
||||
async fn test(_arg: [u8; 16]) {}
|
||||
|
||||
async fn use_future(fut: impl std::future::Future<Output = ()>) {
|
||||
fut.await
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let actual = std::mem::size_of_val(
|
||||
&use_future(use_future(use_future(use_future(use_future(test([0; 16])))))));
|
||||
// Not using an exact number in case it slightly changes over different commits
|
||||
let expected = 550;
|
||||
assert!(actual > expected, "expected: >{expected}, actual: {actual}");
|
||||
}
|
18
tests/ui/async-await/future-sizes/large-arg.rs
Normal file
18
tests/ui/async-await/future-sizes/large-arg.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// compile-flags: -Z print-type-sizes --crate-type=lib
|
||||
// edition: 2021
|
||||
// build-pass
|
||||
// ignore-pass
|
||||
|
||||
pub async fn test() {
|
||||
let _ = a([0u8; 1024]).await;
|
||||
}
|
||||
|
||||
pub async fn a<T>(t: T) -> T {
|
||||
b(t).await
|
||||
}
|
||||
async fn b<T>(t: T) -> T {
|
||||
c(t).await
|
||||
}
|
||||
async fn c<T>(t: T) -> T {
|
||||
t
|
||||
}
|
60
tests/ui/async-await/future-sizes/large-arg.stdout
Normal file
60
tests/ui/async-await/future-sizes/large-arg.stdout
Normal file
|
@ -0,0 +1,60 @@
|
|||
print-type-size type: `[async fn body@$DIR/large-arg.rs:6:21: 8:2]`: 3076 bytes, alignment: 1 bytes
|
||||
print-type-size discriminant: 1 bytes
|
||||
print-type-size variant `Suspend0`: 3075 bytes
|
||||
print-type-size local `.__awaitee`: 3075 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size variant `Unresumed`: 0 bytes
|
||||
print-type-size variant `Returned`: 0 bytes
|
||||
print-type-size variant `Panicked`: 0 bytes
|
||||
print-type-size type: `[async fn body@$DIR/large-arg.rs:10:30: 12:2]`: 3075 bytes, alignment: 1 bytes
|
||||
print-type-size discriminant: 1 bytes
|
||||
print-type-size variant `Suspend0`: 3074 bytes
|
||||
print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size local `.__awaitee`: 2050 bytes
|
||||
print-type-size variant `Unresumed`: 1024 bytes
|
||||
print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size variant `Returned`: 1024 bytes
|
||||
print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size variant `Panicked`: 1024 bytes
|
||||
print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/large-arg.rs:10:30: 12:2]>`: 3075 bytes, alignment: 1 bytes
|
||||
print-type-size field `.value`: 3075 bytes
|
||||
print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/large-arg.rs:10:30: 12:2]>`: 3075 bytes, alignment: 1 bytes
|
||||
print-type-size variant `MaybeUninit`: 3075 bytes
|
||||
print-type-size field `.uninit`: 0 bytes
|
||||
print-type-size field `.value`: 3075 bytes
|
||||
print-type-size type: `[async fn body@$DIR/large-arg.rs:13:26: 15:2]`: 2050 bytes, alignment: 1 bytes
|
||||
print-type-size discriminant: 1 bytes
|
||||
print-type-size variant `Suspend0`: 2049 bytes
|
||||
print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size local `.__awaitee`: 1025 bytes
|
||||
print-type-size variant `Unresumed`: 1024 bytes
|
||||
print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size variant `Returned`: 1024 bytes
|
||||
print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size variant `Panicked`: 1024 bytes
|
||||
print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/large-arg.rs:13:26: 15:2]>`: 2050 bytes, alignment: 1 bytes
|
||||
print-type-size field `.value`: 2050 bytes
|
||||
print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/large-arg.rs:13:26: 15:2]>`: 2050 bytes, alignment: 1 bytes
|
||||
print-type-size variant `MaybeUninit`: 2050 bytes
|
||||
print-type-size field `.uninit`: 0 bytes
|
||||
print-type-size field `.value`: 2050 bytes
|
||||
print-type-size type: `[async fn body@$DIR/large-arg.rs:16:26: 18:2]`: 1025 bytes, alignment: 1 bytes
|
||||
print-type-size discriminant: 1 bytes
|
||||
print-type-size variant `Unresumed`: 1024 bytes
|
||||
print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size variant `Returned`: 1024 bytes
|
||||
print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size variant `Panicked`: 1024 bytes
|
||||
print-type-size upvar `.t`: 1024 bytes, offset: 0 bytes, alignment: 1 bytes
|
||||
print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/large-arg.rs:16:26: 18:2]>`: 1025 bytes, alignment: 1 bytes
|
||||
print-type-size field `.value`: 1025 bytes
|
||||
print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/large-arg.rs:16:26: 18:2]>`: 1025 bytes, alignment: 1 bytes
|
||||
print-type-size variant `MaybeUninit`: 1025 bytes
|
||||
print-type-size field `.uninit`: 0 bytes
|
||||
print-type-size field `.value`: 1025 bytes
|
||||
print-type-size type: `std::task::Poll<[u8; 1024]>`: 1025 bytes, alignment: 1 bytes
|
||||
print-type-size discriminant: 1 bytes
|
||||
print-type-size variant `Ready`: 1024 bytes
|
||||
print-type-size field `.0`: 1024 bytes
|
||||
print-type-size variant `Pending`: 0 bytes
|
Loading…
Add table
Add a link
Reference in a new issue