1
Fork 0

Address review comments

This fixes the issues pointed out in review.
This commit is contained in:
Tom Tromey 2018-09-07 09:29:40 -06:00
parent 71ce4c3007
commit c32f402749

View file

@ -33,7 +33,8 @@ use rustc_data_structures::fingerprint::Fingerprint;
use rustc::ty::Instance; use rustc::ty::Instance;
use common::{CodegenCx, C_u64}; use common::{CodegenCx, C_u64};
use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt}; 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::session::config;
use rustc::util::nodemap::FxHashMap; use rustc::util::nodemap::FxHashMap;
use rustc_fs_util::path2cstr; use rustc_fs_util::path2cstr;
@ -1635,16 +1636,15 @@ fn prepare_enum_metadata(
&layout::Variants::NicheFilling { ref niche, .. } => { &layout::Variants::NicheFilling { ref niche, .. } => {
// Find the integer type of the correct size. // Find the integer type of the correct size.
let discr_type = niche.value.to_ty(cx.tcx); let size = niche.value.size(cx);
let (size, align) = cx.size_and_align_of(discr_type); let align = niche.value.align(cx);
let discr_type = (match size.bits() { let discr_type = match niche.value {
8 => Integer::I8, layout::Int(t, _) => t,
16 => Integer::I16, layout::Float(layout::FloatTy::F32) => Integer::I32,
32 => Integer::I32, layout::Float(layout::FloatTy::F64) => Integer::I64,
64 => Integer::I64, layout::Pointer => cx.data_layout().ptr_sized_integer(),
bits => bug!("prepare_enum_metadata: unknown niche bit size {}", bits), }.to_ty(cx.tcx, false);
}).to_ty(cx.tcx, false);
let discr_metadata = basic_type_metadata(cx, discr_type); let discr_metadata = basic_type_metadata(cx, discr_type);
unsafe { unsafe {