Skip to content

Conversation

pnkfelix
Copy link
Contributor

@pnkfelix pnkfelix commented Jan 31, 2023

For example, for this code:

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 [email protected]: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 [email protected]: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 #62958 )

@rustbot
Copy link
Collaborator

rustbot commented Jan 31, 2023

r? @michaelwoerister

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 31, 2023
@compiler-errors
Copy link
Member

r=me once CI is happy

@pnkfelix
Copy link
Contributor Author

pnkfelix commented Feb 1, 2023

@bors r=compiler-errors rollup=true

@bors
Copy link
Collaborator

bors commented Feb 1, 2023

📌 Commit 362c4fa has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 1, 2023
@compiler-errors
Copy link
Member

@bors rollup=always

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 1, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#107389 (Fixing confusion between mod and remainder)
 - rust-lang#107442 (improve panic message for slice windows and chunks)
 - rust-lang#107470 (Small bootstrap improvements)
 - rust-lang#107487 (Make the "extra if in let...else block" hint a suggestion)
 - rust-lang#107499 (Do not depend on Generator trait when deducing closure signature)
 - rust-lang#107533 (Extend `-Z print-type-sizes` to distinguish generator upvars+locals from "normal" fields.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f41f154 into rust-lang:master Feb 1, 2023
@rustbot rustbot added this to the 1.69.0 milestone Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants