[debuginfo] Make 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.
This commit is contained in:
parent
1481fd964b
commit
0cd2dd7263
11 changed files with 56 additions and 48 deletions
|
@ -59,7 +59,13 @@ fn push_debuginfo_type_name<'tcx>(
|
|||
match *t.kind() {
|
||||
ty::Bool => output.push_str("bool"),
|
||||
ty::Char => output.push_str("char"),
|
||||
ty::Str => output.push_str("str"),
|
||||
ty::Str => {
|
||||
if cpp_like_debuginfo {
|
||||
output.push_str("str$")
|
||||
} else {
|
||||
output.push_str("str")
|
||||
}
|
||||
}
|
||||
ty::Never => {
|
||||
if cpp_like_debuginfo {
|
||||
output.push_str("never$");
|
||||
|
@ -152,25 +158,19 @@ fn push_debuginfo_type_name<'tcx>(
|
|||
}
|
||||
}
|
||||
ty::Ref(_, inner_type, mutbl) => {
|
||||
// Slices and `&str` are treated like C++ pointers when computing debug
|
||||
// info for MSVC debugger. However, wrapping these types' names in a synthetic type
|
||||
// causes the .natvis engine for WinDbg to fail to display their data, so we opt these
|
||||
// types out to aid debugging in MSVC.
|
||||
let is_slice_or_str = matches!(*inner_type.kind(), ty::Slice(_) | ty::Str);
|
||||
|
||||
if !cpp_like_debuginfo {
|
||||
output.push('&');
|
||||
output.push_str(mutbl.prefix_str());
|
||||
} else if !is_slice_or_str {
|
||||
if cpp_like_debuginfo {
|
||||
match mutbl {
|
||||
Mutability::Not => output.push_str("ref$<"),
|
||||
Mutability::Mut => output.push_str("ref_mut$<"),
|
||||
}
|
||||
} else {
|
||||
output.push('&');
|
||||
output.push_str(mutbl.prefix_str());
|
||||
}
|
||||
|
||||
push_debuginfo_type_name(tcx, inner_type, qualified, output, visited);
|
||||
|
||||
if cpp_like_debuginfo && !is_slice_or_str {
|
||||
if cpp_like_debuginfo {
|
||||
push_close_angle_bracket(cpp_like_debuginfo, output);
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ fn push_debuginfo_type_name<'tcx>(
|
|||
}
|
||||
ty::Slice(inner_type) => {
|
||||
if cpp_like_debuginfo {
|
||||
output.push_str("slice$<");
|
||||
output.push_str("slice2$<");
|
||||
} else {
|
||||
output.push('[');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue