Pretty-printing support for Rust generators #62572
Support printing Rust generators in a way that looks more like enums. Generators (as of #59897) are represented in Rust as variant layouts with some extra fields on the outer layout. These extra fields (which are upvars, captured from the environment of the generator closure) seem to cause printing to become less pretty.
Today printing a Rust generator from
Note that we print the fields of every single variant, even though the discriminant is marked in the DWARF output.
Here's the test which produced the above output. The above excerpt is from the second print in the test.
I also opened this bug on GDB; I'm not sure how much we upstream pretty printing support today.
The text was updated successfully, but these errors were encountered:
Fix debuginfo for generators First, all fields except the discriminant (including `outer_fields`) should be put into structures inside the variant part, which gives an equivalent layout but offers us much better integration with debuggers. Second, artificial flags in generator variants should be removed. - Literally, variants are not artificial. We have `yield` statements, upvars and inner variables in the source code. - Functionally, we don't want debuggers to suppress the variants. It contains the state of the generator, which is useful when debugging. So they shouldn't be marked artificial. - Debuggers may use artificial flags to find the active variant. In this case, marking variants artificial will make debuggers not work properly. Fixes rust-lang#62572. Fixes rust-lang#79009. And refer https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Debuginfo.20for.20generators.