Sort Generator print-type-sizes according to their yield points

Especially when trying to diagnose runaway future sizes, it might be
more intuitive to sort the variants according to the control flow
(aka their yield points) rather than the size of the variants.
This commit is contained in:
Arpad Borsos 2023-02-05 16:26:51 +01:00
parent 7f97aeaf73
commit dae00152e7
No known key found for this signature in database
GPG key ID: FC7BCA77824B3298
6 changed files with 25 additions and 12 deletions

View file

@ -970,7 +970,7 @@ fn variant_info_for_generator<'tcx>(
})
.collect();
let variant_infos: Vec<_> = generator
let mut variant_infos: Vec<_> = generator
.variant_fields
.iter_enumerated()
.map(|(variant_idx, variant_def)| {
@ -1033,6 +1033,15 @@ fn variant_info_for_generator<'tcx>(
}
})
.collect();
// The first three variants are hardcoded to be `UNRESUMED`, `RETURNED` and `POISONED`.
// We will move the `RETURNED` and `POISONED` elements to the end so we
// are left with a sorting order according to the generators yield points:
// First `Unresumed`, then the `SuspendN` followed by `Returned` and `Panicked` (POISONED).
let end_states = variant_infos.drain(1..=2);
let end_states: Vec<_> = end_states.collect();
variant_infos.extend(end_states);
(
variant_infos,
match tag_encoding {