diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2020-12-01 10:50:10 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-01 10:50:10 +0000 |
| commit | 08b171726cf978ce27b00190f22140dde0dcfccf (patch) | |
| tree | 8680adba01c90174a047a950bb6aeb8a87e0b33f | |
| parent | b565fe241e9a3a29d725468fdf8da65622665444 (diff) | |
| parent | 36e6aa0aa686049736810d7444c1bfca8e14d38d (diff) | |
Rollup merge of #79184 - nanguye2496:nanguye2496/fix_slice_and_str_type_name, r=varkor
Stop adding '*' at the end of slice and str typenames for MSVC case When computing debug info for MSVC debuggers, Rust compiler emits C++ style type names for compatibility with .natvis visualizers. All Ref types are treated as equivalences of C++ pointers in this process, and, as a result, their type names end with a '\*'. Since Slice and Str are treated as Ref by the compiler, their type names also end with a '\*'. This causes the .natvis engine for WinDbg fails to display data of Slice and Str objects. We addressed this problem simply by removing the '*' at the end of type names for Slice and Str types. Debug info in WinDbg before the fix:  Debug info in WinDbg after the fix:  This change has also been tested with debuggers for Visual Studio, VS Code C++ and VS Code LLDB to make sure that it does not affect the behavior of other kinds of debugger.
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index 896af8a9191..d1bbf74307c 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -94,7 +94,14 @@ pub fn push_debuginfo_type_name<'tcx>( push_debuginfo_type_name(tcx, inner_type, true, output, visited); if cpp_like_names { - output.push('*'); + // Slices and `&str` are treated like C++ pointers when computing debug + // info for MSVC debugger. However, adding '*' at the end of these types' names + // causes the .natvis engine for WinDbg to fail to display their data, so we opt these + // types out to aid debugging in MSVC. + match *inner_type.kind() { + ty::Slice(_) | ty::Str => {} + _ => output.push('*'), + } } } ty::Array(inner_type, len) => { |
