Skip to content

Commit c32f402

Browse files
committed
Address review comments
This fixes the issues pointed out in review.
1 parent 71ce4c3 commit c32f402

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/librustc_codegen_llvm/debuginfo/metadata.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ use rustc_data_structures::fingerprint::Fingerprint;
3333
use rustc::ty::Instance;
3434
use common::{CodegenCx, C_u64};
3535
use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt};
36-
use rustc::ty::layout::{self, Align, Integer, IntegerExt, LayoutOf, PrimitiveExt, Size, TyLayout};
36+
use rustc::ty::layout::{self, Align, HasDataLayout, Integer, IntegerExt, LayoutOf,
37+
PrimitiveExt, Size, TyLayout};
3738
use rustc::session::config;
3839
use rustc::util::nodemap::FxHashMap;
3940
use rustc_fs_util::path2cstr;
@@ -1635,16 +1636,15 @@ fn prepare_enum_metadata(
16351636

16361637
&layout::Variants::NicheFilling { ref niche, .. } => {
16371638
// Find the integer type of the correct size.
1638-
let discr_type = niche.value.to_ty(cx.tcx);
1639-
let (size, align) = cx.size_and_align_of(discr_type);
1640-
1641-
let discr_type = (match size.bits() {
1642-
8 => Integer::I8,
1643-
16 => Integer::I16,
1644-
32 => Integer::I32,
1645-
64 => Integer::I64,
1646-
bits => bug!("prepare_enum_metadata: unknown niche bit size {}", bits),
1647-
}).to_ty(cx.tcx, false);
1639+
let size = niche.value.size(cx);
1640+
let align = niche.value.align(cx);
1641+
1642+
let discr_type = match niche.value {
1643+
layout::Int(t, _) => t,
1644+
layout::Float(layout::FloatTy::F32) => Integer::I32,
1645+
layout::Float(layout::FloatTy::F64) => Integer::I64,
1646+
layout::Pointer => cx.data_layout().ptr_sized_integer(),
1647+
}.to_ty(cx.tcx, false);
16481648

16491649
let discr_metadata = basic_type_metadata(cx, discr_type);
16501650
unsafe {

0 commit comments

Comments
 (0)