diff options
| -rw-r--r-- | src/librustc/ty/layout.rs | 23 | ||||
| -rw-r--r-- | src/librustc_trans/abi.rs | 2 | ||||
| -rw-r--r-- | src/librustc_trans/debuginfo/metadata.rs | 11 | ||||
| -rw-r--r-- | src/librustc_trans/mir/constant.rs | 10 | ||||
| -rw-r--r-- | src/librustc_trans/mir/lvalue.rs | 18 |
5 files changed, 32 insertions, 32 deletions
diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index d905592347f..a0c0fb481aa 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -9,7 +9,6 @@ // except according to those terms. pub use self::Integer::*; -pub use self::Layout::*; pub use self::Primitive::*; use session::{self, DataTypeKind, Session}; @@ -2015,10 +2014,10 @@ impl<'a, 'tcx> FullLayout<'tcx> { }; let (layout, fields, abi) = match *self.layout { - Univariant => (self.layout, self.fields, self.abi), + Layout::Univariant => (self.layout, self.fields, self.abi), - NullablePointer { ref variants, .. } | - General { ref variants, .. } => { + Layout::NullablePointer { ref variants, .. } | + Layout::General { ref variants, .. } => { let variant = &variants[variant_index]; (&variant.layout, &variant.fields, variant.abi) } @@ -2104,8 +2103,8 @@ impl<'a, 'tcx> FullLayout<'tcx> { match self.variant_index { None => match *self.layout { // Discriminant field for enums (where applicable). - General { discr, .. } | - NullablePointer { discr, .. } => { + Layout::General { discr, .. } | + Layout::NullablePointer { discr, .. } => { return [discr.to_ty(tcx)][i]; } _ if def.variants.len() > 1 => return [][i], @@ -2174,10 +2173,10 @@ impl<'a, 'tcx> FullLayout<'tcx> { { let tcx = cx.tcx(); match (self.layout, self.abi, &self.ty.sty) { - (&Scalar, Abi::Scalar(Pointer), _) if !self.ty.is_unsafe_ptr() => { + (&Layout::Scalar, Abi::Scalar(Pointer), _) if !self.ty.is_unsafe_ptr() => { Ok(Some((Size::from_bytes(0), Pointer))) } - (&General { discr, .. }, _, &ty::TyAdt(def, _)) => { + (&Layout::General { discr, .. }, _, &ty::TyAdt(def, _)) => { if def.discriminants(tcx).all(|d| d.to_u128_unchecked() != 0) { Ok(Some((self.fields.offset(0), discr))) } else { @@ -2185,7 +2184,7 @@ impl<'a, 'tcx> FullLayout<'tcx> { } } - (&FatPointer, _, _) if !self.ty.is_unsafe_ptr() => { + (&Layout::FatPointer, _, _) if !self.ty.is_unsafe_ptr() => { Ok(Some((self.fields.offset(FAT_PTR_ADDR), Pointer))) } @@ -2193,10 +2192,10 @@ impl<'a, 'tcx> FullLayout<'tcx> { (_, _, &ty::TyAdt(def, _)) if Some(def.did) == tcx.lang_items().non_zero() => { let field = self.field(cx, 0)?; match (field.layout, field.abi) { - (&Scalar, Abi::Scalar(value)) => { + (&Layout::Scalar, Abi::Scalar(value)) => { Ok(Some((self.fields.offset(0), value))) } - (&FatPointer, _) => { + (&Layout::FatPointer, _) => { Ok(Some((self.fields.offset(0) + field.fields.offset(FAT_PTR_ADDR), Pointer))) @@ -2206,7 +2205,7 @@ impl<'a, 'tcx> FullLayout<'tcx> { } // Perhaps one of the fields is non-zero, let's recurse and find out. - (&Univariant, _, _) => { + (&Layout::Univariant, _, _) => { for i in 0..self.fields.count() { let r = self.field(cx, i)?.non_zero_field(cx)?; if let Some((offset, primitive)) = r { diff --git a/src/librustc_trans/abi.rs b/src/librustc_trans/abi.rs index 365570edd65..6aa49080dd0 100644 --- a/src/librustc_trans/abi.rs +++ b/src/librustc_trans/abi.rs @@ -766,7 +766,7 @@ impl<'a, 'tcx> FnType<'tcx> { for ty in inputs.iter().chain(extra_args.iter()) { let mut arg = arg_of(ty, false); - if let ty::layout::FatPointer { .. } = *arg.layout.layout { + if let ty::layout::Layout::FatPointer { .. } = *arg.layout.layout { let mut data = ArgType::new(arg.layout.field(ccx, 0)); let mut info = ArgType::new(arg.layout.field(ccx, 1)); diff --git a/src/librustc_trans/debuginfo/metadata.rs b/src/librustc_trans/debuginfo/metadata.rs index 5948c3a3e59..f488ebaa4f5 100644 --- a/src/librustc_trans/debuginfo/metadata.rs +++ b/src/librustc_trans/debuginfo/metadata.rs @@ -1130,7 +1130,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> { -> Vec<MemberDescription> { let adt = &self.enum_type.ty_adt_def().unwrap(); match *self.type_rep.layout { - layout::General { ref variants, .. } => { + layout::Layout::General { ref variants, .. } => { let discriminant_info = RegularDiscriminant(self.discriminant_type_metadata .expect("")); (0..variants.len()).map(|i| { @@ -1159,7 +1159,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> { } }).collect() }, - layout::Univariant => { + layout::Layout::Univariant => { assert!(adt.variants.len() <= 1); if adt.variants.is_empty() { @@ -1191,7 +1191,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> { ] } } - layout::NullablePointer { + layout::Layout::NullablePointer { nndiscr, discr, .. @@ -1432,8 +1432,9 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let type_rep = cx.layout_of(enum_type); let discriminant_type_metadata = match *type_rep.layout { - layout::NullablePointer { .. } | layout::Univariant { .. } => None, - layout::General { discr, .. } => Some(discriminant_type_metadata(discr)), + layout::Layout::NullablePointer { .. } | + layout::Layout::Univariant { .. } => None, + layout::Layout::General { discr, .. } => Some(discriminant_type_metadata(discr)), ref l @ _ => bug!("Not an enum layout: {:#?}", l) }; diff --git a/src/librustc_trans/mir/constant.rs b/src/librustc_trans/mir/constant.rs index ae19c865d1c..9c43d8b3627 100644 --- a/src/librustc_trans/mir/constant.rs +++ b/src/librustc_trans/mir/constant.rs @@ -1091,7 +1091,7 @@ fn trans_const_adt<'a, 'tcx>( _ => 0, }; match *l.layout { - layout::General { .. } => { + layout::Layout::General { .. } => { let discr = match *kind { mir::AggregateKind::Adt(adt_def, _, _, _) => { adt_def.discriminant_for_variant(ccx.tcx(), variant_index) @@ -1108,7 +1108,7 @@ fn trans_const_adt<'a, 'tcx>( build_const_struct(ccx, l.for_variant(variant_index), vals, Some(discr)) } } - layout::UntaggedUnion => { + layout::Layout::UntaggedUnion => { assert_eq!(variant_index, 0); let contents = [ vals[0].llval, @@ -1117,14 +1117,14 @@ fn trans_const_adt<'a, 'tcx>( Const::new(C_struct(ccx, &contents, l.is_packed()), t) } - layout::Univariant => { + layout::Layout::Univariant => { assert_eq!(variant_index, 0); build_const_struct(ccx, l, vals, None) } - layout::Vector => { + layout::Layout::Vector => { Const::new(C_vector(&vals.iter().map(|x| x.llval).collect::<Vec<_>>()), t) } - layout::NullablePointer { nndiscr, .. } => { + layout::Layout::NullablePointer { nndiscr, .. } => { if variant_index as u64 == nndiscr { build_const_struct(ccx, l.for_variant(variant_index), vals, None) } else { diff --git a/src/librustc_trans/mir/lvalue.rs b/src/librustc_trans/mir/lvalue.rs index b72ccf6ba28..f6c260e4c15 100644 --- a/src/librustc_trans/mir/lvalue.rs +++ b/src/librustc_trans/mir/lvalue.rs @@ -312,8 +312,8 @@ impl<'a, 'tcx> LvalueRef<'tcx> { let cast_to = bcx.ccx.immediate_llvm_type_of(cast_to); match *l.layout { - layout::Univariant { .. } | - layout::UntaggedUnion { .. } => return C_uint(cast_to, 0), + layout::Layout::Univariant { .. } | + layout::Layout::UntaggedUnion { .. } => return C_uint(cast_to, 0), _ => {} } @@ -324,7 +324,7 @@ impl<'a, 'tcx> LvalueRef<'tcx> { _ => bug!("discriminant not scalar: {:#?}", discr_layout) }; let (min, max) = match *l.layout { - layout::General { ref discr_range, .. } => (discr_range.start, discr_range.end), + layout::Layout::General { ref discr_range, .. } => (discr_range.start, discr_range.end), _ => (0, u64::max_value()), }; let max_next = max.wrapping_add(1); @@ -350,14 +350,14 @@ impl<'a, 'tcx> LvalueRef<'tcx> { } }; match *l.layout { - layout::General { .. } => { + layout::Layout::General { .. } => { let signed = match discr_scalar { layout::Int(_, signed) => signed, _ => false }; bcx.intcast(lldiscr, cast_to, signed) } - layout::NullablePointer { nndiscr, .. } => { + layout::Layout::NullablePointer { nndiscr, .. } => { let cmp = if nndiscr == 0 { llvm::IntEQ } else { llvm::IntNE }; let zero = C_null(bcx.ccx.llvm_type_of(discr_layout.ty)); bcx.intcast(bcx.icmp(cmp, lldiscr, zero), cast_to, false) @@ -374,12 +374,12 @@ impl<'a, 'tcx> LvalueRef<'tcx> { .discriminant_for_variant(bcx.tcx(), variant_index) .to_u128_unchecked() as u64; match *l.layout { - layout::General { .. } => { + layout::Layout::General { .. } => { let ptr = self.project_field(bcx, 0); bcx.store(C_int(bcx.ccx.llvm_type_of(ptr.ty.to_ty(bcx.tcx())), to as i64), ptr.llval, ptr.alignment.non_abi()); } - layout::NullablePointer { nndiscr, .. } => { + layout::Layout::NullablePointer { nndiscr, .. } => { if to != nndiscr { let use_memset = match l.abi { layout::Abi::Scalar(_) => false, @@ -429,8 +429,8 @@ impl<'a, 'tcx> LvalueRef<'tcx> { // If this is an enum, cast to the appropriate variant struct type. let layout = bcx.ccx.layout_of(ty); match *layout.layout { - layout::NullablePointer { .. } | - layout::General { .. } => { + layout::Layout::NullablePointer { .. } | + layout::Layout::General { .. } => { let variant_layout = layout.for_variant(variant_index); let variant_ty = Type::struct_(bcx.ccx, &type_of::struct_llfields(bcx.ccx, variant_layout), |
