about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm/debuginfo
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-03-08 19:54:57 +0000
committerbors <bors@rust-lang.org>2020-03-08 19:54:57 +0000
commit2cb0b8582ebbf9784db9cec06fff517badbf4553 (patch)
treee9d43ec6f39de515bf629881b438fcd8db31b0af /src/librustc_codegen_llvm/debuginfo
parent564758c4c329e89722454dd2fbb35f1ac0b8b47c (diff)
parentc934c94212755eee25e86d9d49fb057073a28b91 (diff)
downloadrust-2cb0b8582ebbf9784db9cec06fff517badbf4553.tar.gz
rust-2cb0b8582ebbf9784db9cec06fff517badbf4553.zip
Auto merge of #69833 - Centril:rollup-mh74yue, r=Centril
Rollup of 7 pull requests

Successful merges:

 - #69120 (Don't give invalid suggestion on desugared span.)
 - #69326 (mir-interpret: add method to read wide strings from Memory)
 - #69608 (Expose target libdir information via print command)
 - #69734 (Change DIBuilderCreateEnumerator signature to match LLVM 9)
 - #69800 (Compile address sanitizer test with debuginfo)
 - #69807 (Cleanup E0391 explanation)
 - #69820 (clean up E0392 explanation)

Failed merges:

r? @ghost
Diffstat (limited to 'src/librustc_codegen_llvm/debuginfo')
-rw-r--r--src/librustc_codegen_llvm/debuginfo/metadata.rs23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs
index 9e52598f2e0..19bd0b6f7e6 100644
--- a/src/librustc_codegen_llvm/debuginfo/metadata.rs
+++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs
@@ -1779,13 +1779,20 @@ fn prepare_enum_metadata(
                 .discriminants(cx.tcx)
                 .zip(&def.variants)
                 .map(|((_, discr), v)| {
-                    let name = SmallCStr::new(&v.ident.as_str());
+                    let name = v.ident.as_str();
+                    let is_unsigned = match discr.ty.kind {
+                        ty::Int(_) => false,
+                        ty::Uint(_) => true,
+                        _ => bug!("non integer discriminant"),
+                    };
                     unsafe {
                         Some(llvm::LLVMRustDIBuilderCreateEnumerator(
                             DIB(cx),
-                            name.as_ptr(),
+                            name.as_ptr().cast(),
+                            name.len(),
                             // FIXME: what if enumeration has i128 discriminant?
-                            discr.val as u64,
+                            discr.val as i64,
+                            is_unsigned,
                         ))
                     }
                 })
@@ -1794,13 +1801,15 @@ fn prepare_enum_metadata(
                 .as_generator()
                 .variant_range(enum_def_id, cx.tcx)
                 .map(|variant_index| {
-                    let name = SmallCStr::new(&substs.as_generator().variant_name(variant_index));
+                    let name = substs.as_generator().variant_name(variant_index);
                     unsafe {
                         Some(llvm::LLVMRustDIBuilderCreateEnumerator(
                             DIB(cx),
-                            name.as_ptr(),
-                            // FIXME: what if enumeration has i128 discriminant?
-                            variant_index.as_usize() as u64,
+                            name.as_ptr().cast(),
+                            name.len(),
+                            // Generators use u32 as discriminant type.
+                            variant_index.as_u32().into(),
+                            true, // IsUnsigned
                         ))
                     }
                 })