diff options
| author | MaulingMonkey <git@maulingmonkey.com> | 2017-07-19 16:36:09 -0700 |
|---|---|---|
| committer | MaulingMonkey <git@maulingmonkey.com> | 2017-07-19 16:36:09 -0700 |
| commit | cfc128cea4d10827be2178bac66dc23888c02092 (patch) | |
| tree | d87a5dc488115141511dc8342a3ba84bcf6f1b57 | |
| parent | 8e10c4d55d5a21c879c01c57211579239f08d0b0 (diff) | |
| download | rust-cfc128cea4d10827be2178bac66dc23888c02092.tar.gz rust-cfc128cea4d10827be2178bac66dc23888c02092.zip | |
Expand one-liners, rename is_like_msvc to cpp_like_names and explain.
| -rw-r--r-- | src/librustc_trans/debuginfo/type_names.rs | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/src/librustc_trans/debuginfo/type_names.rs b/src/librustc_trans/debuginfo/type_names.rs index 9ab5bc4a5a9..6e36073107b 100644 --- a/src/librustc_trans/debuginfo/type_names.rs +++ b/src/librustc_trans/debuginfo/type_names.rs @@ -36,6 +36,10 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>, qualified: bool, output: &mut String) { + // When targeting MSVC, emit C++ style type names for compatability with + // .natvis visualizers (and perhaps other existing native debuggers?) + let cpp_like_names = cx.sess().target.target.options.is_like_msvc; + match t.sty { ty::TyBool => output.push_str("bool"), ty::TyChar => output.push_str("char"), @@ -61,27 +65,33 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, output.push(')'); }, ty::TyRawPtr(ty::TypeAndMut { ty: inner_type, mutbl } ) => { - let is_like_msvc = cx.sess().target.target.options.is_like_msvc; - - if !is_like_msvc {output.push('*');} + if !cpp_like_names { + output.push('*'); + } match mutbl { hir::MutImmutable => output.push_str("const "), hir::MutMutable => output.push_str("mut "), } push_debuginfo_type_name(cx, inner_type, true, output); - if is_like_msvc {output.push('*');} + + if cpp_like_names { + output.push('*'); + } }, ty::TyRef(_, ty::TypeAndMut { ty: inner_type, mutbl }) => { - let is_like_msvc = cx.sess().target.target.options.is_like_msvc; - - if !is_like_msvc {output.push('&');} + if !cpp_like_names { + output.push('&'); + } if mutbl == hir::MutMutable { output.push_str("mut "); } push_debuginfo_type_name(cx, inner_type, true, output); - if is_like_msvc {output.push('*');} + + if cpp_like_names { + output.push('*'); + } }, ty::TyArray(inner_type, len) => { output.push('['); @@ -90,10 +100,19 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, output.push(']'); }, ty::TySlice(inner_type) => { - let is_like_msvc = cx.sess().target.target.options.is_like_msvc; - output.push_str(if is_like_msvc {"slice<"} else {"["}); + if cpp_like_names { + output.push_str("slice<"); + } else { + output.push('['); + } + push_debuginfo_type_name(cx, inner_type, true, output); - output.push(if is_like_msvc {'>'} else {']'}); + + if cpp_like_names { + output.push('>'); + } else { + output.push(']'); + } }, ty::TyDynamic(ref trait_data, ..) => { if let Some(principal) = trait_data.principal() { |
