about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm/debuginfo
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-09-07 09:29:40 -0600
committerTom Tromey <tom@tromey.com>2018-10-30 12:06:07 -0600
commitc32f402749214840eb1ae73577d5e0864d43a056 (patch)
tree861c877900e79b5f26b9914da7f6acaa68446913 /src/librustc_codegen_llvm/debuginfo
parent71ce4c3007b964208b89733b0931bf71e7514938 (diff)
downloadrust-c32f402749214840eb1ae73577d5e0864d43a056.tar.gz
rust-c32f402749214840eb1ae73577d5e0864d43a056.zip
Address review comments
This fixes the issues pointed out in review.
Diffstat (limited to 'src/librustc_codegen_llvm/debuginfo')
-rw-r--r--src/librustc_codegen_llvm/debuginfo/metadata.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs
index 6290f5c8e67..19ada960db3 100644
--- a/src/librustc_codegen_llvm/debuginfo/metadata.rs
+++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs
@@ -33,7 +33,8 @@ use rustc_data_structures::fingerprint::Fingerprint;
 use rustc::ty::Instance;
 use common::{CodegenCx, C_u64};
 use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt};
-use rustc::ty::layout::{self, Align, Integer, IntegerExt, LayoutOf, PrimitiveExt, Size, TyLayout};
+use rustc::ty::layout::{self, Align, HasDataLayout, Integer, IntegerExt, LayoutOf,
+                        PrimitiveExt, Size, TyLayout};
 use rustc::session::config;
 use rustc::util::nodemap::FxHashMap;
 use rustc_fs_util::path2cstr;
@@ -1635,16 +1636,15 @@ fn prepare_enum_metadata(
 
         &layout::Variants::NicheFilling { ref niche, .. } => {
             // Find the integer type of the correct size.
-            let discr_type = niche.value.to_ty(cx.tcx);
-            let (size, align) = cx.size_and_align_of(discr_type);
-
-            let discr_type = (match size.bits() {
-                8 => Integer::I8,
-                16 => Integer::I16,
-                32 => Integer::I32,
-                64 => Integer::I64,
-                bits => bug!("prepare_enum_metadata: unknown niche bit size {}", bits),
-            }).to_ty(cx.tcx, false);
+            let size = niche.value.size(cx);
+            let align = niche.value.align(cx);
+
+            let discr_type = match niche.value {
+                layout::Int(t, _) => t,
+                layout::Float(layout::FloatTy::F32) => Integer::I32,
+                layout::Float(layout::FloatTy::F64) => Integer::I64,
+                layout::Pointer => cx.data_layout().ptr_sized_integer(),
+            }.to_ty(cx.tcx, false);
 
             let discr_metadata = basic_type_metadata(cx, discr_type);
             unsafe {