rust/compiler/rustc_codegen_ssa/src
bors b0f3940c35 Auto merge of #103691 - michaelwoerister:consistent-slice-and-str-cpp-like-debuginfo-names, r=wesleywiser
[debuginfo] Make cpp-like debuginfo type names for slices and str consistent.

Before this PR, the compiler would emit the debuginfo name `slice$<T>` for all kinds of slices, regardless of whether they are behind a reference or not and regardless of the kind of reference. As a consequence, the types `Foo<&[T]>`, `Foo<[T]>`, and `Foo<&mut [T]>` would end up with the same type name `Foo<slice$<T> >` in debuginfo, making it impossible to disambiguate between them by name. Similarly, `&str` would get the name `str` in debuginfo, so the debuginfo name for `Foo<str>` and `Foo<&str>` would be the same. In contrast, `*const [bool]` and `*mut [bool]` would be `ptr_const$<slice$<bool> >` and `ptr_mut$<slice$<bool> >`, i.e. the encoding does not lose information about the type.

This PR removes all special handling for slices and `str`. The types `&[bool]`, `&mut [bool]`, and `&str` thus get the names `ref$<slice2$<bool> >`, `ref_mut$<slice2$<bool> >`, and `ref$<str$>` respectively -- as one would expect.

The new special name for slices is `slice2$` to differentiate it from the previous name `slice$`, which has different semantics. The same is true for `str` and `str$`. This kind of versioning already has a precedent with the case of `enum$` and `enum2$` and hopefully will make it easier to transition existing consumers of these names.

cc `@rust-lang/wg-debugging` `@vadimcn`

r? `@wesleywiser`

UPDATE: Here is a table to clarify the changes

| Rust type | DWARF name | C++-like name (before) | C++-like name (after) |
|-----------|------------|------------------------|------------------------|
| `[T]`        | `[T]`        | `slice$<T>`              | `slice2$<T>`           |
| `&[T]`       | `&[T]`       | `slice$<T>`              | `ref$<slice2$<T> >`    |
| `&mut [T]`   | `&mut [T]`   | `slice$<T>`              | `ref_mut$<slice2$<T> >`|
| `str`        | `str`        | `str`                    | `str$`           |
| `&str`       | `&str`       | `str`                    | `ref$<str$>`    |
| `&mut str`   | `&mut str`   | `str`                    | `ref_mut$<str$>`|
| `*const [T]` | `*const [T]` | `ptr_const$<slice$<T> >` | `ptr_const$<slice2$<T> >` |
| `*mut [T]`   | `*mut [T]`   | `ptr_mut$<slice$<T> >`   | `ptr_mut$<slice2$<T> >` |

As you can see, before the PR many types would end up with the same name, making it impossible to distinguish between them in NatVis or other places where types are matched or looked up by name. The DWARF version of names is not changed.
2022-11-05 11:07:50 +00:00
..
back Rollup merge of #103660 - ozkanonur:master, r=jyn514 2022-11-05 11:31:28 +05:30
coverageinfo Remove in_band_lifetimes from rustc_codegen_ssa 2021-12-15 00:41:41 -05:00
debuginfo [debuginfo] Make debuginfo type names for slices and str consistent. 2022-10-31 15:43:44 +01:00
mir Use br instead of switch in more cases. 2022-10-31 10:16:39 +11:00
traits Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +00:00
base.rs Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +00:00
common.rs Simplify cast_shift_expr_rhs. 2022-10-25 14:39:20 +11:00
errors.rs UPDATE - accept dyn error and make Box<dyn error> conform to IntoDiagnosticArg 2022-11-04 01:17:03 -04:00
glue.rs use unchecked mul to compute slice sizes 2022-06-14 17:09:07 -04:00
lib.rs ADD - initial port of link.rs 2022-10-07 10:03:45 -04:00
meth.rs Call destructors when dyn* object goes out of scope 2022-09-12 16:55:57 -07:00
mono_item.rs Add codegen for global_asm! sym operands 2022-04-15 14:36:30 +01:00
target_features.rs Add multivalue target feature to WASM target 2022-10-27 18:08:30 +02:00