Commit f41f154
authored
Rollup merge of rust-lang#107533 - pnkfelix:distinguish-generator-state-in-print-type-sizes, r=compiler-errors
Extend `-Z print-type-sizes` to distinguish generator upvars+locals from "normal" fields.
For example, for this code:
```rust
async fn wait() {}
async fn test(arg: [u8; 8192]) {
wait().await;
drop(arg);
}
async fn test_ideal(_rg: [u8; 8192]) {
wait().await;
// drop(arg);
}
fn main() {
let gen_t = test([0; 8192]);
let gen_i = test_ideal([0; 8192]);
println!("expect {}, got: {}",
std::mem::size_of_val(&gen_i),
std::mem::size_of_val(&gen_t));
}
```
the `-Z print-type-sizes` output used to start with:
```
print-type-size type: `[async fn body@issue-62958-a.rs:3:32: 6:2]`: 16386 bytes, alignment: 1 bytes
print-type-size discriminant: 1 bytes
print-type-size variant `Suspend0`: 16385 bytes
print-type-size field `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
print-type-size field `.arg`: 8192 bytes
print-type-size field `.__awaitee`: 1 bytes
...
print-type-size type: `std::mem::ManuallyDrop<[u8; 8192]>`: 8192 bytes, alignment: 1 bytes
print-type-size field `.value`: 8192 bytes
...
```
but with this change, it now instead prints:
```
print-type-size type: `[async fn body@issue-62958-a.rs:3:32: 6:2]`: 16386 bytes, alignment: 1 bytes
print-type-size discriminant: 1 bytes
print-type-size variant `Suspend0`: 16385 bytes
print-type-size upvar `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
print-type-size local `.arg`: 8192 bytes
print-type-size local `.__awaitee`: 1 bytes
...
print-type-size type: `std::mem::ManuallyDrop<[u8; 8192]>`: 8192 bytes, alignment: 1 bytes
print-type-size field `.value`: 8192 bytes
```
(spawned off of investigation of rust-lang#62958 )File tree
6 files changed
+39
-18
lines changed- compiler
- rustc_session/src
- rustc_ty_utils/src
- tests/ui/print_type_sizes
6 files changed
+39
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
22 | 39 | | |
23 | 40 | | |
| 41 | + | |
24 | 42 | | |
25 | 43 | | |
26 | 44 | | |
| |||
145 | 163 | | |
146 | 164 | | |
147 | 165 | | |
148 | | - | |
| 166 | + | |
149 | 167 | | |
150 | 168 | | |
151 | 169 | | |
| |||
155 | 173 | | |
156 | 174 | | |
157 | 175 | | |
158 | | - | |
| 176 | + | |
159 | 177 | | |
160 | 178 | | |
161 | 179 | | |
162 | 180 | | |
163 | | - | |
| 181 | + | |
164 | 182 | | |
165 | 183 | | |
166 | 184 | | |
167 | | - | |
| 185 | + | |
168 | 186 | | |
169 | 187 | | |
170 | 188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
881 | 881 | | |
882 | 882 | | |
883 | 883 | | |
| 884 | + | |
884 | 885 | | |
885 | 886 | | |
886 | 887 | | |
| |||
960 | 961 | | |
961 | 962 | | |
962 | 963 | | |
| 964 | + | |
963 | 965 | | |
964 | 966 | | |
965 | 967 | | |
| |||
983 | 985 | | |
984 | 986 | | |
985 | 987 | | |
| 988 | + | |
986 | 989 | | |
987 | 990 | | |
988 | 991 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
0 commit comments