Skip to content

Commit 4273141

Browse files
committed
Address review comments
This fixes the issues pointed out in review.
1 parent 85bc80f commit 4273141

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;
@@ -1648,16 +1649,15 @@ fn prepare_enum_metadata(
16481649

16491650
&layout::Variants::NicheFilling { ref niche, .. } => {
16501651
// Find the integer type of the correct size.
1651-
let discr_type = niche.value.to_ty(cx.tcx);
1652-
let (size, align) = cx.size_and_align_of(discr_type);
1653-
1654-
let discr_type = (match size.bits() {
1655-
8 => Integer::I8,
1656-
16 => Integer::I16,
1657-
32 => Integer::I32,
1658-
64 => Integer::I64,
1659-
bits => bug!("prepare_enum_metadata: unknown niche bit size {}", bits),
1660-
}).to_ty(cx.tcx, false);
1652+
let size = niche.value.size(cx);
1653+
let align = niche.value.align(cx);
1654+
1655+
let discr_type = match niche.value {
1656+
layout::Int(t, _) => t,
1657+
layout::Float(layout::FloatTy::F32) => Integer::I32,
1658+
layout::Float(layout::FloatTy::F64) => Integer::I64,
1659+
layout::Pointer => cx.data_layout().ptr_sized_integer(),
1660+
}.to_ty(cx.tcx, false);
16611661

16621662
let discr_metadata = basic_type_metadata(cx, discr_type);
16631663
unsafe {

0 commit comments

Comments
 (0)