Skip to content

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

@pnkfelix

Description

@pnkfelix
Member

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 generator@ex-1.rs: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 generator@ex-1.rs: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 generator@ex-1.rs: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>

Activity

added a commit that references this issue on Dec 10, 2022
0f5d3ba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

C-bugCategory: This is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @pnkfelix@compiler-errors

    Issue actions

      -Z print-type-sizes does not include the size of a generator itself · Issue #103887 · rust-lang/rust