Repository: rust
Issue: debuginfo: Enums, generators, and async envs have generic arguments at the wrong level
Labels: A-debuginfo,T-compiler,A-technical-debt,WG-debugging

Currently, the compiler emits debuginfo that attaches generic arguments to the type of each variant instead of at the top-level. For example, the enum

```rust
enum Foo<T> {
   Bar(T),
   Baz(u32),
}
```

gets described as if it was

```rust
enum Foo {
   Bar<T>(T),
   Baz<T>(u32),
}
```

It would be more consistent and efficient if the generic arguments were pulled into the type describing `Foo`.

The main obstacle to doing so is making sure that this change does not break existing tooling.

Here is some actual DWARF (for the `Poll` enum) to illustrate the issue:

```txt
< 4><0x000007b4>          DW_TAG_structure_type
                            DW_AT_name                  Poll<u8>
                            DW_AT_byte_size             0x00000002
                            DW_AT_alignment             0x00000001
< 5><0x000007bb>            DW_TAG_variant_part
                              DW_AT_discr                 <0x000007c0>
< 6><0x000007c0>              DW_TAG_member
                                DW_AT_type                  <0x00001335>
                                DW_AT_alignment             0x00000001
                                DW_AT_data_member_location  0
                                DW_AT_artificial            yes(1)
< 6><0x000007c7>              DW_TAG_variant
                                DW_AT_discr_value           0
< 7><0x000007c9>                DW_TAG_member
                                  DW_AT_name                  Ready
                                  DW_AT_type                  <0x000007e4>
                                  DW_AT_alignment             0x00000001
                                  DW_AT_data_member_location  0
< 6><0x000007d5>              DW_TAG_variant
                                DW_AT_discr_value           1
< 7><0x000007d7>                DW_TAG_member
                                  DW_AT_name                  Pending
                                  DW_AT_type                  <0x00000800>
                                  DW_AT_alignment             0x00000001
                                  DW_AT_data_member_location  0
< 5><0x000007e4>            DW_TAG_structure_type
                              DW_AT_name                  Ready
                              DW_AT_byte_size             0x00000002
                              DW_AT_alignment             0x00000001
< 6><0x000007eb>              DW_TAG_template_type_parameter
                                DW_AT_type                  <0x00001335>
                                DW_AT_name                  T
< 6><0x000007f4>              DW_TAG_member
                                DW_AT_name                  __0
                                DW_AT_type                  <0x00001335>
                                DW_AT_alignment             0x00000001
                                DW_AT_data_member_location  1
< 5><0x00000800>            DW_TAG_structure_type
                              DW_AT_name                  Pending
                              DW_AT_byte_size             0x00000002
                              DW_AT_alignment             0x00000001
< 6><0x00000807>              DW_TAG_template_type_parameter
                                DW_AT_type                  <0x00001335>
                                DW_AT_name                  T
```
There should be a single `DW_TAG_template_type_parameter` DIE attached to the top-level `DW_TAG_structure_type` instead of duplicated across the `DW_TAG_structure_type`s for `Ready` and `Pending`.