rustc: re-complicate the TyLayout API and use better names.

This commit is contained in:
Eduard-Mihai Burtescu 2017-09-13 00:33:56 +03:00
parent aa811d728a
commit 8864668d53
18 changed files with 114 additions and 125 deletions

View File

@ -227,12 +227,6 @@ impl<'a> HasDataLayout for &'a TargetDataLayout {
}
}
impl<'a, 'tcx> HasDataLayout for TyCtxt<'a, 'tcx, 'tcx> {
fn data_layout(&self) -> &TargetDataLayout {
&self.data_layout
}
}
/// Endianness of the target, which must match cfg(target-endian).
#[derive(Copy, Clone)]
pub enum Endian {
@ -2089,80 +2083,85 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> {
}
}
/// A pair of a type and its layout. Implements various
/// type traversal APIs (e.g. recursing into fields).
/// The details of the layout of a type, alongside the type itself.
/// Provides various type traversal APIs (e.g. recursing into fields).
///
/// Note that the details are NOT guaranteed to always be identical
/// to those obtained from `layout_of(ty)`, as we need to produce
/// layouts for which Rust types do not exist, such as enum variants
/// or synthetic fields of enums (i.e. discriminants) and fat pointers.
#[derive(Copy, Clone, Debug)]
pub struct TyLayout<'tcx> {
pub struct FullLayout<'tcx> {
pub ty: Ty<'tcx>,
pub layout: &'tcx Layout,
pub variant_index: Option<usize>,
pub layout: &'tcx Layout,
}
impl<'tcx> Deref for TyLayout<'tcx> {
impl<'tcx> Deref for FullLayout<'tcx> {
type Target = Layout;
fn deref(&self) -> &Layout {
self.layout
}
}
pub trait LayoutTyper<'tcx>: HasDataLayout {
type TyLayout;
pub trait HasTyCtxt<'tcx>: HasDataLayout {
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx>;
fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout;
fn normalize_projections(self, ty: Ty<'tcx>) -> Ty<'tcx>;
}
/// Combines a tcx with the parameter environment so that you can
/// compute layout operations.
#[derive(Copy, Clone)]
pub struct LayoutCx<'a, 'tcx: 'a> {
tcx: TyCtxt<'a, 'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
}
impl<'a, 'tcx> LayoutCx<'a, 'tcx> {
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>) -> Self {
LayoutCx { tcx, param_env }
}
}
impl<'a, 'tcx> HasDataLayout for LayoutCx<'a, 'tcx> {
impl<'a, 'gcx, 'tcx> HasDataLayout for TyCtxt<'a, 'gcx, 'tcx> {
fn data_layout(&self) -> &TargetDataLayout {
&self.tcx.data_layout
&self.data_layout
}
}
impl<'a, 'tcx> LayoutTyper<'tcx> for LayoutCx<'a, 'tcx> {
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> {
self.tcx
impl<'a, 'gcx, 'tcx> HasTyCtxt<'gcx> for TyCtxt<'a, 'gcx, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'gcx> {
self.global_tcx()
}
}
fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout {
let ty = self.normalize_projections(ty);
impl<'a, 'gcx, 'tcx, T: Copy> HasDataLayout for (TyCtxt<'a, 'gcx, 'tcx>, T) {
fn data_layout(&self) -> &TargetDataLayout {
self.0.data_layout()
}
}
Ok(TyLayout {
impl<'a, 'gcx, 'tcx, T: Copy> HasTyCtxt<'gcx> for (TyCtxt<'a, 'gcx, 'tcx>, T) {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'gcx> {
self.0.tcx()
}
}
pub trait LayoutOf<T> {
type FullLayout;
fn layout_of(self, ty: T) -> Self::FullLayout;
}
impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for (TyCtxt<'a, 'tcx, 'tcx>, ty::ParamEnv<'tcx>) {
type FullLayout = Result<FullLayout<'tcx>, LayoutError<'tcx>>;
fn layout_of(self, ty: Ty<'tcx>) -> Self::FullLayout {
let (tcx, param_env) = self;
let ty = tcx.normalize_associated_type_in_env(&ty, param_env);
Ok(FullLayout {
ty,
layout: ty.layout(self.tcx, self.param_env)?,
variant_index: None
variant_index: None,
layout: ty.layout(tcx, param_env)?,
})
}
fn normalize_projections(self, ty: Ty<'tcx>) -> Ty<'tcx> {
self.tcx.normalize_associated_type_in_env(&ty, self.param_env)
}
}
impl<'a, 'tcx> TyLayout<'tcx> {
impl<'a, 'tcx> FullLayout<'tcx> {
pub fn for_variant(&self, variant_index: usize) -> Self {
let is_enum = match self.ty.sty {
ty::TyAdt(def, _) => def.is_enum(),
_ => false
};
assert!(is_enum);
TyLayout {
FullLayout {
variant_index: Some(variant_index),
..*self
}
@ -2199,7 +2198,7 @@ impl<'a, 'tcx> TyLayout<'tcx> {
match *self.layout {
Scalar { .. } => {
bug!("TyLayout::field_count({:?}): not applicable", self)
bug!("FullLayout::field_count({:?}): not applicable", self)
}
// Handled above (the TyAdt case).
@ -2222,9 +2221,7 @@ impl<'a, 'tcx> TyLayout<'tcx> {
}
}
fn field_type_unnormalized<C: LayoutTyper<'tcx>>(&self, cx: C, i: usize) -> Ty<'tcx> {
let tcx = cx.tcx();
fn field_type_unnormalized(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, i: usize) -> Ty<'tcx> {
let ptr_field_type = |pointee: Ty<'tcx>| {
assert!(i < 2);
let slice = |element: Ty<'tcx>| {
@ -2238,7 +2235,7 @@ impl<'a, 'tcx> TyLayout<'tcx> {
ty::TySlice(element) => slice(element),
ty::TyStr => slice(tcx.types.u8),
ty::TyDynamic(..) => tcx.mk_mut_ptr(tcx.mk_nil()),
_ => bug!("TyLayout::field_type({:?}): not applicable", self)
_ => bug!("FullLayout::field_type({:?}): not applicable", self)
}
};
@ -2253,7 +2250,7 @@ impl<'a, 'tcx> TyLayout<'tcx> {
ty::TyFnDef(..) |
ty::TyDynamic(..) |
ty::TyForeign(..) => {
bug!("TyLayout::field_type({:?}): not applicable", self)
bug!("FullLayout::field_type({:?}): not applicable", self)
}
// Potentially-fat pointers.
@ -2311,20 +2308,16 @@ impl<'a, 'tcx> TyLayout<'tcx> {
ty::TyProjection(_) | ty::TyAnon(..) | ty::TyParam(_) |
ty::TyInfer(_) | ty::TyError => {
bug!("TyLayout::field_type: unexpected type `{}`", self.ty)
bug!("FullLayout::field_type: unexpected type `{}`", self.ty)
}
}
}
pub fn field_type<C: LayoutTyper<'tcx>>(&self, cx: C, i: usize) -> Ty<'tcx> {
cx.normalize_projections(self.field_type_unnormalized(cx, i))
}
pub fn field<C: LayoutTyper<'tcx>>(&self,
cx: C,
i: usize)
-> C::TyLayout {
cx.layout_of(self.field_type(cx, i))
pub fn field<C: LayoutOf<Ty<'tcx>> + HasTyCtxt<'tcx>>(&self,
cx: C,
i: usize)
-> C::FullLayout {
cx.layout_of(self.field_type_unnormalized(cx.tcx(), i))
}
}

View File

@ -35,8 +35,8 @@ use type_::Type;
use rustc::hir;
use rustc::ty::{self, Ty};
use rustc::ty::layout::{self, Align, Layout, Size, TyLayout};
use rustc::ty::layout::{HasDataLayout, LayoutTyper};
use rustc::ty::layout::{self, Align, Layout, Size, FullLayout};
use rustc::ty::layout::{HasDataLayout, LayoutOf};
use rustc_back::PanicStrategy;
use libc::c_uint;
@ -274,7 +274,7 @@ pub trait LayoutExt<'tcx> {
fn homogeneous_aggregate<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> Option<Reg>;
}
impl<'tcx> LayoutExt<'tcx> for TyLayout<'tcx> {
impl<'tcx> LayoutExt<'tcx> for FullLayout<'tcx> {
fn is_aggregate(&self) -> bool {
match *self.layout {
Layout::Scalar { .. } |
@ -471,7 +471,7 @@ impl CastTarget {
#[derive(Clone, Copy, Debug)]
pub struct ArgType<'tcx> {
kind: ArgKind,
pub layout: TyLayout<'tcx>,
pub layout: FullLayout<'tcx>,
/// Cast target, either a single uniform or a pair of registers.
pub cast: Option<CastTarget>,
/// Dummy argument, which is emitted before the real argument.
@ -481,7 +481,7 @@ pub struct ArgType<'tcx> {
}
impl<'a, 'tcx> ArgType<'tcx> {
fn new(layout: TyLayout<'tcx>) -> ArgType<'tcx> {
fn new(layout: FullLayout<'tcx>) -> ArgType<'tcx> {
ArgType {
kind: ArgKind::Direct,
layout,

View File

@ -42,7 +42,7 @@
//! taken to it, implementing them for Rust seems difficult.
use rustc::ty::{self, Ty};
use rustc::ty::layout::{self, Align, HasDataLayout, LayoutTyper, Size, TyLayout};
use rustc::ty::layout::{self, Align, HasDataLayout, LayoutOf, Size, FullLayout};
use context::CrateContext;
use type_::Type;
@ -207,7 +207,7 @@ pub fn memory_index_to_gep(index: u64) -> u64 {
}
pub fn struct_llfields<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
layout: TyLayout<'tcx>,
layout: FullLayout<'tcx>,
variant: &layout::Struct) -> Vec<Type> {
let field_count = layout.field_count();
debug!("struct_llfields: variant: {:?}", variant);

View File

@ -14,7 +14,7 @@
use abi::{FnType, ArgType, LayoutExt, Reg};
use context::CrateContext;
use rustc::ty::layout::{self, Layout, TyLayout};
use rustc::ty::layout::{self, Layout, FullLayout};
fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tcx>) {
if !ret.layout.is_aggregate() && ret.layout.size(ccx).bits() <= 64 {
@ -25,7 +25,7 @@ fn classify_ret_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ret: &mut ArgType<'tc
}
fn is_single_fp_element<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
layout: TyLayout<'tcx>) -> bool {
layout: FullLayout<'tcx>) -> bool {
match *layout {
Layout::Scalar { value: layout::F32, .. } |
Layout::Scalar { value: layout::F64, .. } => true,

View File

@ -11,7 +11,7 @@
use abi::{ArgAttribute, FnType, LayoutExt, Reg, RegKind};
use common::CrateContext;
use rustc::ty::layout::{self, Layout, TyLayout};
use rustc::ty::layout::{self, Layout, FullLayout};
#[derive(PartialEq)]
pub enum Flavor {
@ -20,7 +20,7 @@ pub enum Flavor {
}
fn is_single_fp_element<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
layout: TyLayout<'tcx>) -> bool {
layout: FullLayout<'tcx>) -> bool {
match *layout {
Layout::Scalar { value: layout::F32, .. } |
Layout::Scalar { value: layout::F64, .. } => true,

View File

@ -14,7 +14,7 @@
use abi::{ArgType, ArgAttribute, CastTarget, FnType, LayoutExt, Reg, RegKind};
use context::CrateContext;
use rustc::ty::layout::{self, Layout, TyLayout, Size};
use rustc::ty::layout::{self, Layout, FullLayout, Size};
#[derive(Clone, Copy, PartialEq, Debug)]
enum Class {
@ -53,7 +53,7 @@ fn classify_arg<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, arg: &ArgType<'tcx>)
}
fn classify<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
layout: TyLayout<'tcx>,
layout: FullLayout<'tcx>,
cls: &mut [Class],
off: Size)
-> Result<(), Memory> {

View File

@ -27,7 +27,7 @@ use type_::Type;
use value::Value;
use rustc::traits;
use rustc::ty::{self, Ty, TyCtxt};
use rustc::ty::layout::{HasDataLayout, Layout, LayoutTyper};
use rustc::ty::layout::{HasDataLayout, Layout, LayoutOf};
use rustc::ty::subst::{Kind, Subst, Substs};
use rustc::hir;
@ -81,8 +81,8 @@ pub fn type_is_imm_pair<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>)
}
// The two fields must be both immediates.
type_is_immediate(ccx, layout.field_type(ccx, 0)) &&
type_is_immediate(ccx, layout.field_type(ccx, 1))
type_is_immediate(ccx, layout.field(ccx, 0).ty) &&
type_is_immediate(ccx, layout.field(ccx, 1).ty)
}
_ => false
}

View File

@ -29,7 +29,7 @@ use rustc::middle::trans::Stats;
use rustc_data_structures::stable_hasher::StableHashingContextProvider;
use rustc::session::config::{self, NoDebugInfo};
use rustc::session::Session;
use rustc::ty::layout::{LayoutCx, LayoutError, LayoutTyper, TyLayout};
use rustc::ty::layout::{LayoutError, LayoutOf, FullLayout};
use rustc::ty::{self, Ty, TyCtxt};
use rustc::util::nodemap::FxHashMap;
use rustc_trans_utils;
@ -648,48 +648,44 @@ impl<'a, 'tcx> ty::layout::HasDataLayout for &'a SharedCrateContext<'a, 'tcx> {
}
}
impl<'a, 'tcx> ty::layout::HasTyCtxt<'tcx> for &'a SharedCrateContext<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> {
self.tcx
}
}
impl<'a, 'tcx> ty::layout::HasDataLayout for &'a CrateContext<'a, 'tcx> {
fn data_layout(&self) -> &ty::layout::TargetDataLayout {
&self.shared.tcx.data_layout
}
}
impl<'a, 'tcx> LayoutTyper<'tcx> for &'a SharedCrateContext<'a, 'tcx> {
type TyLayout = TyLayout<'tcx>;
impl<'a, 'tcx> ty::layout::HasTyCtxt<'tcx> for &'a CrateContext<'a, 'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> {
self.tcx
self.shared.tcx
}
}
fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout {
let param_env = ty::ParamEnv::empty(traits::Reveal::All);
LayoutCx::new(self.tcx, param_env)
impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for &'a SharedCrateContext<'a, 'tcx> {
type FullLayout = FullLayout<'tcx>;
fn layout_of(self, ty: Ty<'tcx>) -> Self::FullLayout {
(self.tcx, ty::ParamEnv::empty(traits::Reveal::All))
.layout_of(ty)
.unwrap_or_else(|e| match e {
LayoutError::SizeOverflow(_) => self.sess().fatal(&e.to_string()),
_ => bug!("failed to get layout for `{}`: {}", ty, e)
})
}
fn normalize_projections(self, ty: Ty<'tcx>) -> Ty<'tcx> {
self.tcx().fully_normalize_associated_types_in(&ty)
}
}
impl<'a, 'tcx> LayoutTyper<'tcx> for &'a CrateContext<'a, 'tcx> {
type TyLayout = TyLayout<'tcx>;
impl<'a, 'tcx> LayoutOf<Ty<'tcx>> for &'a CrateContext<'a, 'tcx> {
type FullLayout = FullLayout<'tcx>;
fn tcx<'b>(&'b self) -> TyCtxt<'b, 'tcx, 'tcx> {
self.shared.tcx
}
fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout {
fn layout_of(self, ty: Ty<'tcx>) -> Self::FullLayout {
self.shared.layout_of(ty)
}
fn normalize_projections(self, ty: Ty<'tcx>) -> Ty<'tcx> {
self.shared.normalize_projections(ty)
}
}
/// Declare any llvm intrinsics that you might need

View File

@ -32,7 +32,7 @@ use rustc::ty::util::TypeIdHasher;
use rustc::ich::Fingerprint;
use common::{self, CrateContext};
use rustc::ty::{self, AdtKind, Ty};
use rustc::ty::layout::{self, Align, LayoutTyper, Size, TyLayout};
use rustc::ty::layout::{self, Align, LayoutOf, Size, FullLayout};
use rustc::session::{Session, config};
use rustc::util::nodemap::FxHashMap;
use rustc::util::common::path2cstr;
@ -1072,7 +1072,7 @@ fn prepare_tuple_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
//=-----------------------------------------------------------------------------
struct UnionMemberDescriptionFactory<'tcx> {
layout: TyLayout<'tcx>,
layout: FullLayout<'tcx>,
variant: &'tcx ty::VariantDef,
span: Span,
}
@ -1139,7 +1139,7 @@ fn prepare_union_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// offset of zero bytes).
struct EnumMemberDescriptionFactory<'tcx> {
enum_type: Ty<'tcx>,
type_rep: TyLayout<'tcx>,
type_rep: FullLayout<'tcx>,
discriminant_type_metadata: Option<DIType>,
containing_scope: DIScope,
file_metadata: DIFile,
@ -1318,7 +1318,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
// of discriminant instead of us having to recover its path.
fn compute_field_path<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
name: &mut String,
layout: TyLayout<'tcx>,
layout: FullLayout<'tcx>,
offset: Size,
size: Size) {
for i in 0..layout.field_count() {
@ -1409,13 +1409,13 @@ fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
-> (DICompositeType, MemberDescriptionFactory<'tcx>) {
let layout = cx.layout_of(enum_type);
let maybe_discr = match *layout {
layout::General { .. } => Some(layout.field_type(cx, 0)),
layout::General { .. } => Some(layout.field(cx, 0).ty),
_ => None,
};
let layout = layout.for_variant(variant_index);
let mut field_tys = (0..layout.field_count()).map(|i| {
layout.field_type(cx, i)
layout.field(cx, i).ty
}).collect::<Vec<_>>();
if let Some(discr) = maybe_discr {

View File

@ -43,7 +43,7 @@ use std::ptr;
use syntax_pos::{self, Span, Pos};
use syntax::ast;
use syntax::symbol::Symbol;
use rustc::ty::layout::{self, LayoutTyper};
use rustc::ty::layout::{self, LayoutOf};
pub mod gdb;
mod utils;

View File

@ -19,7 +19,7 @@ use common::*;
use llvm::{ValueRef};
use llvm;
use meth;
use rustc::ty::layout::LayoutTyper;
use rustc::ty::layout::LayoutOf;
use rustc::ty::{self, Ty};
use value::Value;
@ -74,7 +74,7 @@ pub fn size_and_align_of_dst<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, t: Ty<'tcx>, inf
// Recurse to get the size of the dynamically sized field (must be
// the last field).
let field_ty = layout.field_type(ccx, layout.field_count() - 1);
let field_ty = layout.field(ccx, layout.field_count() - 1).ty;
let (unsized_size, unsized_align) = size_and_align_of_dst(bcx, field_ty, info);
// FIXME (#26403, #27023): We should be adding padding

View File

@ -12,7 +12,7 @@ use llvm::{self, ValueRef, BasicBlockRef};
use rustc::middle::lang_items;
use rustc::middle::const_val::{ConstEvalErr, ConstInt, ErrKind};
use rustc::ty::{self, Ty, TypeFoldable};
use rustc::ty::layout::LayoutTyper;
use rustc::ty::layout::LayoutOf;
use rustc::traits;
use rustc::mir;
use abi::{Abi, FnType, ArgType};

View File

@ -18,7 +18,7 @@ use rustc::traits;
use rustc::mir;
use rustc::mir::tcx::LvalueTy;
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
use rustc::ty::layout::{self, LayoutTyper, Size};
use rustc::ty::layout::{self, LayoutOf, Size};
use rustc::ty::cast::{CastTy, IntTy};
use rustc::ty::subst::{Kind, Substs, Subst};
use rustc_apfloat::{ieee, Float, Status};
@ -1157,7 +1157,7 @@ fn trans_const_adt<'a, 'tcx>(
/// a two-element struct will locate it at offset 4, and accesses to it
/// will read the wrong memory.
fn build_const_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
layout: layout::TyLayout<'tcx>,
layout: layout::FullLayout<'tcx>,
st: &layout::Struct,
vals: &[Const<'tcx>],
discr: Option<Const<'tcx>>)

View File

@ -10,7 +10,7 @@
use llvm::{self, ValueRef};
use rustc::ty::{self, Ty, TypeFoldable};
use rustc::ty::layout::{self, Align, Layout, LayoutTyper, Size};
use rustc::ty::layout::{self, Align, Layout, LayoutOf, Size};
use rustc::mir;
use rustc::mir::tcx::LvalueTy;
use rustc_data_structures::indexed_vec::Idx;
@ -205,7 +205,7 @@ impl<'a, 'tcx> LvalueRef<'tcx> {
l = l.for_variant(variant_index)
}
}
let fty = l.field_type(ccx, ix);
let fty = l.field(ccx, ix).ty;
let alignment = self.alignment | Alignment::from(&*l);

View File

@ -12,7 +12,7 @@ use libc::c_uint;
use llvm::{self, ValueRef, BasicBlockRef};
use llvm::debuginfo::DIScope;
use rustc::ty::{self, Ty, TypeFoldable};
use rustc::ty::layout::{self, LayoutTyper};
use rustc::ty::layout::{self, LayoutOf};
use rustc::mir::{self, Mir};
use rustc::ty::subst::Substs;
use rustc::infer::TransNormalize;

View File

@ -10,7 +10,7 @@
use llvm::ValueRef;
use rustc::ty::{self, Ty};
use rustc::ty::layout::LayoutTyper;
use rustc::ty::layout::LayoutOf;
use rustc::mir;
use rustc::mir::tcx::LvalueTy;
use rustc_data_structures::indexed_vec::Idx;
@ -140,10 +140,10 @@ impl<'a, 'tcx> OperandRef<'tcx> {
let layout = bcx.ccx.layout_of(self.ty);
let a = bcx.extract_value(llval, layout.llvm_field_index(0));
let a = base::to_immediate(bcx, a, layout.field_type(bcx.ccx, 0));
let a = base::to_immediate(bcx, a, layout.field(bcx.ccx, 0).ty);
let b = bcx.extract_value(llval, layout.llvm_field_index(1));
let b = base::to_immediate(bcx, b, layout.field_type(bcx.ccx, 1));
let b = base::to_immediate(bcx, b, layout.field(bcx.ccx, 1).ty);
self.val = OperandValue::Pair(a, b);
}

View File

@ -11,7 +11,7 @@
use llvm::{self, ValueRef};
use rustc::ty::{self, Ty};
use rustc::ty::cast::{CastTy, IntTy};
use rustc::ty::layout::{Layout, LayoutTyper};
use rustc::ty::layout::{Layout, LayoutOf};
use rustc::mir;
use rustc::middle::lang_items::ExchangeMallocFnLangItem;
use rustc_apfloat::{ieee, Float, Status, Round};

View File

@ -12,7 +12,7 @@ use abi::FnType;
use adt;
use common::*;
use rustc::ty::{self, Ty, TypeFoldable};
use rustc::ty::layout::{Align, Layout, LayoutTyper, Size, TyLayout};
use rustc::ty::layout::{Align, Layout, LayoutOf, Size, FullLayout};
use trans_item::DefPathBasedNames;
use type_::Type;
@ -235,14 +235,14 @@ pub trait LayoutLlvmExt {
fn llvm_field_index(&self, index: usize) -> u64;
}
impl<'tcx> LayoutLlvmExt for TyLayout<'tcx> {
impl<'tcx> LayoutLlvmExt for FullLayout<'tcx> {
fn llvm_field_index(&self, index: usize) -> u64 {
match **self {
Layout::Scalar { .. } |
Layout::CEnum { .. } |
Layout::UntaggedUnion { .. } |
Layout::RawNullablePointer { .. } => {
bug!("TyLayout::llvm_field_index({:?}): not applicable", self)
bug!("FullLayout::llvm_field_index({:?}): not applicable", self)
}
Layout::Vector { .. } |
@ -271,7 +271,7 @@ impl<'tcx> LayoutLlvmExt for TyLayout<'tcx> {
if self.variant_index == Some(nndiscr as usize) {
adt::memory_index_to_gep(nonnull.memory_index[index] as u64)
} else {
bug!("TyLayout::llvm_field_index({:?}): not applicable", self)
bug!("FullLayout::llvm_field_index({:?}): not applicable", self)
}
}
}