Skip to content

-Z print-type-sizes does not include the size of a generator itself #103887

Closed
@pnkfelix

Description

@pnkfelix

I tried this code:

async fn wait() {}

async fn test(arg: [u8; 8192]) {
    wait().await;
    drop(arg);
}

fn main() {
    println!("{}", std::mem::size_of_val(&test([0; 8192])));
}

and then I ran rustc +nightly --edition 2021 ex-1.rs -Z print-type-sizes

I expected to see this happen: Somewhere in the output, I expected to see

print-type-size type: `[static [email protected]:5:32: 8:2]`: 16386 bytes, alignment 1 bytes

Instead, this happened: I do see info about a bunch of types that use the above type, and it is enough information for me to extract my most immediate question (the size of the type), such as:

print-type-size type: `std::future::from_generator::GenFuture<[static [email protected]:7:32: 10:2]>`: 16386 bytes, alignment: 1 bytes
print-type-size     field `.0`: 16386 bytes

But it would provide a more consistent experience overall if we would print out a separate line for the [static [email protected]:7:32: 10:2] type itself, especially if it could also provide insight into the pieces of state that have been captured by the generator itself.

Meta

rustc --version --verbose:

<version>
Backtrace

<backtrace>

Metadata

Metadata

Labels

C-bugCategory: This is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions