rust/compiler/rustc_session/src
Matthias Krüger f41f154dfb
Rollup merge of #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 https://github.com/rust-lang/rust/issues/62958 )
2023-02-01 05:54:40 +01:00
..
config Change process spawning to inherit the parent's signal mask by default 2022-10-20 14:53:38 -07:00
cgu_reuse_tracker.rs Remove useless borrows and derefs 2022-12-01 17:34:43 +00:00
code_stats.rs placate tidy. 2023-01-31 17:10:58 -05:00
config.rs session: impl IntoDiagnosticArg for CrateType 2023-01-30 17:11:34 +00:00
cstore.rs Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
errors.rs session: diagnostic migration lint on more fns 2023-01-30 17:11:35 +00:00
filesearch.rs Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
lib.rs remove cfg(bootstrap) 2022-09-26 10:14:45 +02:00
options.rs Auto merge of #106227 - bryangarza:ctfe-limit, r=oli-obk 2023-01-29 04:11:27 +00:00
output.rs Auto merge of #106810 - oli-obk:resolver_reverse_plumbing, r=petrochenkov 2023-01-19 05:23:40 +00:00
parse.rs rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
search_paths.rs incr. comp.: Don't export impl_stable_hash_via_hash!() and warn about using it. 2022-04-19 10:43:20 +02:00
session.rs Rollup merge of #107533 - pnkfelix:distinguish-generator-state-in-print-type-sizes, r=compiler-errors 2023-02-01 05:54:40 +01:00
utils.rs rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00