Rollup merge of #104019 - compiler-errors:print-generator-sizes, r=wesleywiser

Compute generator sizes with `-Zprint_type_sizes`

Fixes #103887
r? `@pnkfelix`
This commit is contained in:
Matthias Krüger 2022-12-10 09:24:41 +01:00 committed by GitHub
commit 0f5d3ba30f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 286 additions and 104 deletions

View file

@ -0,0 +1,19 @@
// compile-flags: -Z print-type-sizes
// edition:2021
// build-pass
// ignore-pass
#![feature(start)]
async fn wait() {}
async fn test(arg: [u8; 8192]) {
wait().await;
drop(arg);
}
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
let _ = test([0; 8192]);
0
}

View file

@ -0,0 +1,34 @@
print-type-size type: `[async fn body@$DIR/async.rs:10:32: 13: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 variant `Unresumed`: 8192 bytes
print-type-size field `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
print-type-size variant `Returned`: 8192 bytes
print-type-size field `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
print-type-size variant `Panicked`: 8192 bytes
print-type-size field `.arg`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
print-type-size type: `std::mem::ManuallyDrop<[u8; 8192]>`: 8192 bytes, alignment: 1 bytes
print-type-size field `.value`: 8192 bytes
print-type-size type: `std::mem::MaybeUninit<[u8; 8192]>`: 8192 bytes, alignment: 1 bytes
print-type-size variant `MaybeUninit`: 8192 bytes
print-type-size field `.uninit`: 0 bytes
print-type-size field `.value`: 8192 bytes
print-type-size type: `[async fn body@$DIR/async.rs:8:17: 8:19]`: 1 bytes, alignment: 1 bytes
print-type-size discriminant: 1 bytes
print-type-size variant `Unresumed`: 0 bytes
print-type-size variant `Returned`: 0 bytes
print-type-size variant `Panicked`: 0 bytes
print-type-size type: `std::mem::ManuallyDrop<[async fn body@$DIR/async.rs:8:17: 8:19]>`: 1 bytes, alignment: 1 bytes
print-type-size field `.value`: 1 bytes
print-type-size type: `std::mem::MaybeUninit<[async fn body@$DIR/async.rs:8:17: 8:19]>`: 1 bytes, alignment: 1 bytes
print-type-size variant `MaybeUninit`: 1 bytes
print-type-size field `.uninit`: 0 bytes
print-type-size field `.value`: 1 bytes
print-type-size type: `std::task::Poll<()>`: 1 bytes, alignment: 1 bytes
print-type-size discriminant: 1 bytes
print-type-size variant `Ready`: 0 bytes
print-type-size field `.0`: 0 bytes
print-type-size variant `Pending`: 0 bytes

View file

@ -0,0 +1,20 @@
// compile-flags: -Z print-type-sizes
// build-pass
// ignore-pass
#![feature(start, generators, generator_trait)]
use std::ops::Generator;
fn generator<const C: usize>(array: [u8; C]) -> impl Generator<Yield = (), Return = ()> {
move |()| {
yield ();
let _ = array;
}
}
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
let _ = generator([0; 8192]);
0
}

View file

@ -0,0 +1,10 @@
print-type-size type: `[generator@$DIR/generator.rs:10:5: 10:14]`: 8193 bytes, alignment: 1 bytes
print-type-size discriminant: 1 bytes
print-type-size variant `Unresumed`: 8192 bytes
print-type-size field `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
print-type-size variant `Returned`: 8192 bytes
print-type-size field `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
print-type-size variant `Panicked`: 8192 bytes
print-type-size field `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes
print-type-size variant `Suspend0`: 8192 bytes
print-type-size field `.array`: 8192 bytes, offset: 0 bytes, alignment: 1 bytes