rust/compiler
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
..
rustc rustc: Use unix_sigpipe instead of rustc_driver::set_sigpipe_handler 2022-10-02 17:49:36 +02:00
rustc_apfloat
rustc_arena
rustc_ast rustdoc: use ThinVec for cleaned generics 2022-11-02 16:17:22 -07:00
rustc_ast_lowering rustdoc: use ThinVec for cleaned generics 2022-11-02 16:17:22 -07:00
rustc_ast_passes Rollup merge of #95710 - fee1-dead-contrib:stabilize_arbitrary_enum_discriminant, r=joshtriplett 2022-10-26 17:32:53 +05:30
rustc_ast_pretty Rename AssocItemKind::TyAlias to AssocItemKind::Type 2022-10-10 02:31:37 +00:00
rustc_attr Migrate all diagnostics 2022-10-23 10:09:44 +02:00
rustc_borrowck Rollup merge of #103868 - compiler-errors:trait-engine-less, r=jackh726 2022-11-05 00:02:04 +01:00
rustc_builtin_macros rustdoc: use ThinVec for cleaned generics 2022-11-02 16:17:22 -07:00
rustc_codegen_cranelift Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +00:00
rustc_codegen_gcc Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +00:00
rustc_codegen_llvm Rollup merge of #103977 - TimNN:memory-effects, r=nikic 2022-11-05 00:02:05 +01:00
rustc_codegen_ssa Auto merge of #103691 - michaelwoerister:consistent-slice-and-str-cpp-like-debuginfo-names, r=wesleywiser 2022-11-05 11:07:50 +00:00
rustc_const_eval Rollup merge of #103868 - compiler-errors:trait-engine-less, r=jackh726 2022-11-05 00:02:04 +01:00
rustc_data_structures Rollup merge of #103845 - camsteffen:data-structures-track-caller, r=compiler-errors 2022-11-04 12:18:01 +01:00
rustc_driver Auto merge of #103217 - mejrs:track, r=eholk 2022-11-01 21:09:45 +00:00
rustc_error_codes Update E0382.md 2022-10-31 00:41:12 -04:00
rustc_error_messages Specify that break cannot be used outside of loop *or* labeled block 2022-11-05 01:12:58 +00:00
rustc_errors Rollup merge of #103792 - JhonnyBillM:migrate-codegen-ssa-to-diagnostics-structs-pt2, r=davidtwco 2022-11-04 18:52:27 +01:00
rustc_expand Auto merge of #103217 - mejrs:track, r=eholk 2022-11-01 21:09:45 +00:00
rustc_feature Rewrite implementation of #[alloc_error_handler] 2022-10-31 16:32:57 +00:00
rustc_fs_util
rustc_graphviz
rustc_hir Add visit_fn_ret_ty to hir intravisit 2022-11-03 10:41:22 -03:00
rustc_hir_analysis Rollup merge of #103621 - fee1-dead-contrib:iat-fix-use, r=cjgillot 2022-11-05 11:31:28 +05:30
rustc_hir_pretty pretty: fix to print some lifetimes on HIR pretty-print 2022-10-15 23:34:21 +09:00
rustc_hir_typeck Rollup merge of #103867 - compiler-errors:no-has-errors, r=cjgillot 2022-11-05 11:31:29 +05:30
rustc_incremental Rename some OwnerId fields. 2022-10-29 20:28:38 +11:00
rustc_index Remove from compiler/ crates 2022-09-29 16:49:04 +09:00
rustc_infer Refactor tcx mk_const parameters. 2022-11-04 20:33:32 +00:00
rustc_interface Rollup merge of #103660 - ozkanonur:master, r=jyn514 2022-11-05 11:31:28 +05:30
rustc_lexer rustc_lexer::TokenKind improve docs 2022-10-26 23:32:14 +02:00
rustc_lint Rollup merge of #103868 - compiler-errors:trait-engine-less, r=jackh726 2022-11-05 00:02:04 +01:00
rustc_lint_defs Make PROC_MACRO_DERIVE_RESOLUTION_FALLBACK a hard error 2022-10-24 13:40:07 -05:00
rustc_llvm LLVM 16: Switch to using MemoryEffects 2022-11-04 17:58:16 +00:00
rustc_log
rustc_macros Rollup merge of #103575 - Xiretza:suggestions-style-attr, r=davidtwco 2022-11-01 20:00:38 -04:00
rustc_metadata Auto merge of #103217 - mejrs:track, r=eholk 2022-11-01 21:09:45 +00:00
rustc_middle Rollup merge of #103984 - V0ldek:103974-refactor-mk_const, r=BoxyUwU 2022-11-05 00:02:06 +01:00
rustc_mir_build Rollup merge of #103984 - V0ldek:103974-refactor-mk_const, r=BoxyUwU 2022-11-05 00:02:06 +01:00
rustc_mir_dataflow Migrate all diagnostics 2022-10-23 10:09:44 +02:00
rustc_mir_transform Formatting changes + add UI test 2022-11-04 12:58:20 +00:00
rustc_monomorphize Fix ICE when negative impl is collected during eager mono 2022-11-04 03:08:28 +00:00
rustc_parse Rollup merge of #103703 - Nilstrieb:flag-recovery-1, r=compiler-errors 2022-11-02 22:32:03 +05:30
rustc_parse_format Detect and reject out-of-range integers in format string literals 2022-10-01 01:05:01 +02:00
rustc_passes Specify that break cannot be used outside of loop *or* labeled block 2022-11-05 01:12:58 +00:00
rustc_plugin_impl Migrate all diagnostics 2022-10-23 10:09:44 +02:00
rustc_privacy Rename some OwnerId fields. 2022-10-29 20:28:38 +11:00
rustc_query_impl rustdoc: use ThinVec for cleaned generics 2022-11-02 16:17:22 -07:00
rustc_query_system rustdoc: use ThinVec for cleaned generics 2022-11-02 16:17:22 -07:00
rustc_resolve Rollup merge of #103953 - TaKO8Ki:remove-unused-arg-from-throw_unresolved_import_error, r=oli-obk 2022-11-04 12:18:03 +01:00
rustc_save_analysis Rename some OwnerId fields. 2022-10-29 20:28:38 +11:00
rustc_serialize rustdoc: use ThinVec for cleaned generics 2022-11-02 16:17:22 -07:00
rustc_session Rollup merge of #103660 - ozkanonur:master, r=jyn514 2022-11-05 11:31:28 +05:30
rustc_smir Only keep one version of ImplicitSelfKind. 2022-09-13 19:18:23 +02:00
rustc_span Rollup merge of #97971 - Soveu:varargs, r=jackh726 2022-10-30 19:31:36 -07:00
rustc_symbol_mangling Refactor tcx mk_const parameters. 2022-11-04 20:33:32 +00:00
rustc_target Auto merge of #103455 - BlackHoleFox:apple-sim-abi-consistency, r=davidtwco 2022-11-03 03:07:31 +00:00
rustc_trait_selection Rollup merge of #103984 - V0ldek:103974-refactor-mk_const, r=BoxyUwU 2022-11-05 00:02:06 +01:00
rustc_traits Refactor tcx mk_const parameters. 2022-11-04 20:33:32 +00:00
rustc_transmute Rollup merge of #103915 - chenyukang:yukang/fix-103874, r=lcnr 2022-11-04 06:40:32 +01:00
rustc_ty_utils Refactor tcx mk_const parameters. 2022-11-04 20:33:32 +00:00
rustc_type_ir deprecate DelaySpanBugEmitted and use ErrorGuaranteed directly 2022-11-02 23:15:49 +08:00