Skip to content

Commit 83e15f8

Browse files
committed
Updated the future-sizes tests to opt-into the MIR transformations (regardless
of their default settings) and then updated the numbers to reflect the improvements those transformations now yield.
1 parent e88e117 commit 83e15f8

5 files changed

+145
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:25:21: 28:2]`: 3078 bytes, alignment: 1 bytes
2+
print-type-size discriminant: 1 bytes
3+
print-type-size variant `Unresumed`: 0 bytes
4+
print-type-size variant `Suspend0`: 3077 bytes
5+
print-type-size local `.__awaitee`: 3077 bytes
6+
print-type-size variant `Returned`: 0 bytes
7+
print-type-size variant `Panicked`: 0 bytes
8+
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:14:64: 23:2]`: 3077 bytes, alignment: 1 bytes
9+
print-type-size discriminant: 1 bytes
10+
print-type-size variant `Unresumed`: 1025 bytes
11+
print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
12+
print-type-size variant `Suspend0`: 2052 bytes
13+
print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
14+
print-type-size padding: 1 bytes
15+
print-type-size local `.fut`: 1025 bytes, alignment: 1 bytes
16+
print-type-size local `..generator_field4`: 1 bytes
17+
print-type-size local `.__awaitee`: 1 bytes
18+
print-type-size variant `Suspend1`: 3076 bytes
19+
print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
20+
print-type-size padding: 1026 bytes
21+
print-type-size local `..generator_field4`: 1 bytes, alignment: 1 bytes
22+
print-type-size local `.__awaitee`: 1025 bytes
23+
print-type-size variant `Suspend2`: 2052 bytes
24+
print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
25+
print-type-size padding: 1 bytes
26+
print-type-size local `.fut`: 1025 bytes, alignment: 1 bytes
27+
print-type-size local `..generator_field4`: 1 bytes
28+
print-type-size local `.__awaitee`: 1 bytes
29+
print-type-size variant `Returned`: 1025 bytes
30+
print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
31+
print-type-size variant `Panicked`: 1025 bytes
32+
print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
33+
print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/async-awaiting-fut.rs:14:64: 23:2]>`: 3077 bytes, alignment: 1 bytes
34+
print-type-size field `.value`: 3077 bytes
35+
print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/async-awaiting-fut.rs:14:64: 23:2]>`: 3077 bytes, alignment: 1 bytes
36+
print-type-size variant `MaybeUninit`: 3077 bytes
37+
print-type-size field `.uninit`: 0 bytes
38+
print-type-size field `.value`: 3077 bytes
39+
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:12:35: 12:37]`: 1025 bytes, alignment: 1 bytes
40+
print-type-size discriminant: 1 bytes
41+
print-type-size variant `Unresumed`: 1024 bytes
42+
print-type-size upvar `.arg`: 1024 bytes
43+
print-type-size variant `Returned`: 1024 bytes
44+
print-type-size upvar `.arg`: 1024 bytes
45+
print-type-size variant `Panicked`: 1024 bytes
46+
print-type-size upvar `.arg`: 1024 bytes
47+
print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/async-awaiting-fut.rs:12:35: 12:37]>`: 1025 bytes, alignment: 1 bytes
48+
print-type-size field `.value`: 1025 bytes
49+
print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/async-awaiting-fut.rs:12:35: 12:37]>`: 1025 bytes, alignment: 1 bytes
50+
print-type-size variant `MaybeUninit`: 1025 bytes
51+
print-type-size field `.uninit`: 0 bytes
52+
print-type-size field `.value`: 1025 bytes
53+
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:10:17: 10:19]`: 1 bytes, alignment: 1 bytes
54+
print-type-size discriminant: 1 bytes
55+
print-type-size variant `Unresumed`: 0 bytes
56+
print-type-size variant `Returned`: 0 bytes
57+
print-type-size variant `Panicked`: 0 bytes
58+
print-type-size type: `std::mem::ManuallyDrop<bool>`: 1 bytes, alignment: 1 bytes
59+
print-type-size field `.value`: 1 bytes
60+
print-type-size type: `std::mem::MaybeUninit<bool>`: 1 bytes, alignment: 1 bytes
61+
print-type-size variant `MaybeUninit`: 1 bytes
62+
print-type-size field `.uninit`: 0 bytes
63+
print-type-size field `.value`: 1 bytes
64+
print-type-size type: `std::task::Poll<()>`: 1 bytes, alignment: 1 bytes
65+
print-type-size discriminant: 1 bytes
66+
print-type-size variant `Ready`: 0 bytes
67+
print-type-size field `.0`: 0 bytes
68+
print-type-size variant `Pending`: 0 bytes

tests/ui/async-await/future-sizes/async-awaiting-fut.stdout renamed to tests/ui/async-await/future-sizes/async-awaiting-fut.both_on.stdout

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:21:21: 24:2]`: 1029 bytes, alignment: 1 bytes
1+
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:25:21: 28:2]`: 1029 bytes, alignment: 1 bytes
22
print-type-size discriminant: 1 bytes
33
print-type-size variant `Unresumed`: 0 bytes
44
print-type-size variant `Suspend0`: 1028 bytes
55
print-type-size local `.__awaitee`: 1028 bytes
66
print-type-size variant `Returned`: 0 bytes
77
print-type-size variant `Panicked`: 0 bytes
8-
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:10:64: 19:2]`: 1028 bytes, alignment: 1 bytes
8+
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:14:64: 23:2]`: 1028 bytes, alignment: 1 bytes
99
print-type-size discriminant: 1 bytes
1010
print-type-size variant `Unresumed`: 1025 bytes
1111
print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
@@ -27,21 +27,21 @@ print-type-size variant `Returned`: 1025 bytes
2727
print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
2828
print-type-size variant `Panicked`: 1025 bytes
2929
print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
30-
print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/async-awaiting-fut.rs:10:64: 19:2]>`: 1028 bytes, alignment: 1 bytes
30+
print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/async-awaiting-fut.rs:14:64: 23:2]>`: 1028 bytes, alignment: 1 bytes
3131
print-type-size field `.value`: 1028 bytes
32-
print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/async-awaiting-fut.rs:10:64: 19:2]>`: 1028 bytes, alignment: 1 bytes
32+
print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/async-awaiting-fut.rs:14:64: 23:2]>`: 1028 bytes, alignment: 1 bytes
3333
print-type-size variant `MaybeUninit`: 1028 bytes
3434
print-type-size field `.uninit`: 0 bytes
3535
print-type-size field `.value`: 1028 bytes
36-
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:8:35: 8:37]`: 1025 bytes, alignment: 1 bytes
36+
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:12:35: 12:37]`: 1025 bytes, alignment: 1 bytes
3737
print-type-size discriminant: 1 bytes
3838
print-type-size variant `Unresumed`: 1024 bytes
3939
print-type-size upvar `.arg`: 1024 bytes
4040
print-type-size variant `Returned`: 1024 bytes
4141
print-type-size upvar `.arg`: 1024 bytes
4242
print-type-size variant `Panicked`: 1024 bytes
4343
print-type-size upvar `.arg`: 1024 bytes
44-
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:6:17: 6:19]`: 1 bytes, alignment: 1 bytes
44+
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:10:17: 10:19]`: 1 bytes, alignment: 1 bytes
4545
print-type-size discriminant: 1 bytes
4646
print-type-size variant `Unresumed`: 0 bytes
4747
print-type-size variant `Returned`: 0 bytes
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:25:21: 28:2]`: 2053 bytes, alignment: 1 bytes
2+
print-type-size discriminant: 1 bytes
3+
print-type-size variant `Unresumed`: 0 bytes
4+
print-type-size variant `Suspend0`: 2052 bytes
5+
print-type-size local `.__awaitee`: 2052 bytes
6+
print-type-size variant `Returned`: 0 bytes
7+
print-type-size variant `Panicked`: 0 bytes
8+
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:14:64: 23:2]`: 2052 bytes, alignment: 1 bytes
9+
print-type-size discriminant: 1 bytes
10+
print-type-size variant `Unresumed`: 1025 bytes
11+
print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
12+
print-type-size variant `Suspend0`: 1027 bytes
13+
print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
14+
print-type-size padding: 1 bytes
15+
print-type-size local `..generator_field3`: 1 bytes, alignment: 1 bytes
16+
print-type-size local `.__awaitee`: 1 bytes
17+
print-type-size variant `Suspend1`: 2051 bytes
18+
print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
19+
print-type-size padding: 1 bytes
20+
print-type-size local `..generator_field3`: 1 bytes, alignment: 1 bytes
21+
print-type-size local `.__awaitee`: 1025 bytes
22+
print-type-size variant `Suspend2`: 1027 bytes
23+
print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
24+
print-type-size padding: 1 bytes
25+
print-type-size local `..generator_field3`: 1 bytes, alignment: 1 bytes
26+
print-type-size local `.__awaitee`: 1 bytes
27+
print-type-size variant `Returned`: 1025 bytes
28+
print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
29+
print-type-size variant `Panicked`: 1025 bytes
30+
print-type-size upvar `.fut`: 1025 bytes, offset: 0 bytes, alignment: 1 bytes
31+
print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/async-awaiting-fut.rs:14:64: 23:2]>`: 2052 bytes, alignment: 1 bytes
32+
print-type-size field `.value`: 2052 bytes
33+
print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/async-awaiting-fut.rs:14:64: 23:2]>`: 2052 bytes, alignment: 1 bytes
34+
print-type-size variant `MaybeUninit`: 2052 bytes
35+
print-type-size field `.uninit`: 0 bytes
36+
print-type-size field `.value`: 2052 bytes
37+
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:12:35: 12:37]`: 1025 bytes, alignment: 1 bytes
38+
print-type-size discriminant: 1 bytes
39+
print-type-size variant `Unresumed`: 1024 bytes
40+
print-type-size upvar `.arg`: 1024 bytes
41+
print-type-size variant `Returned`: 1024 bytes
42+
print-type-size upvar `.arg`: 1024 bytes
43+
print-type-size variant `Panicked`: 1024 bytes
44+
print-type-size upvar `.arg`: 1024 bytes
45+
print-type-size type: `[async fn body@$DIR/async-awaiting-fut.rs:10:17: 10:19]`: 1 bytes, alignment: 1 bytes
46+
print-type-size discriminant: 1 bytes
47+
print-type-size variant `Unresumed`: 0 bytes
48+
print-type-size variant `Returned`: 0 bytes
49+
print-type-size variant `Panicked`: 0 bytes
50+
print-type-size type: `std::mem::ManuallyDrop<bool>`: 1 bytes, alignment: 1 bytes
51+
print-type-size field `.value`: 1 bytes
52+
print-type-size type: `std::mem::MaybeUninit<bool>`: 1 bytes, alignment: 1 bytes
53+
print-type-size variant `MaybeUninit`: 1 bytes
54+
print-type-size field `.uninit`: 0 bytes
55+
print-type-size field `.value`: 1 bytes
56+
print-type-size type: `std::task::Poll<()>`: 1 bytes, alignment: 1 bytes
57+
print-type-size discriminant: 1 bytes
58+
print-type-size variant `Ready`: 0 bytes
59+
print-type-size field `.0`: 0 bytes
60+
print-type-size variant `Pending`: 0 bytes

tests/ui/async-await/future-sizes/async-awaiting-fut.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
// compile-flags: -Z print-type-sizes --crate-type lib
1+
// revisions: both_off just_prop both_on
2+
// ignore-tidy-linelength
3+
// [both_off] compile-flags: -Z print-type-sizes --crate-type lib -Z mir-enable-passes=-UpvarToLocalProp,-InlineFutureIntoFuture
4+
// [just_prop] compile-flags: -Z print-type-sizes --crate-type lib -Z mir-enable-passes=+UpvarToLocalProp,-InlineFutureIntoFuture
5+
// [both_on] compile-flags: -Z print-type-sizes --crate-type lib -Z mir-enable-passes=+UpvarToLocalProp,+InlineFutureIntoFuture
26
// edition:2021
37
// build-pass
48
// ignore-pass

tests/ui/async-await/future-sizes/future-as-arg.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// compile-flags: -Z mir-enable-passes=+UpvarToLocalProp,+InlineFutureIntoFuture
12
// edition: 2021
23
// run-pass
34

@@ -10,7 +11,9 @@ async fn use_future(fut: impl std::future::Future<Output = ()>) {
1011
fn main() {
1112
let actual = std::mem::size_of_val(
1213
&use_future(use_future(use_future(use_future(use_future(test([0; 16])))))));
13-
// Not using an exact number in case it slightly changes over different commits
14-
let expected = 20;
15-
assert!(actual > expected, "expected: >{expected}, actual: {actual}");
14+
15+
// Using an acceptable range rather than an exact number, in order to allow
16+
// the actual value to vary slightly over different commits
17+
let expected = 16..=32;
18+
assert!(expected.contains(&actual), "expected: {expected:?}, actual: {actual}");
1619
}

0 commit comments

Comments
 (0)