Skip to content

Commit b2d52d2

Browse files
committed
rustc: do not pub use Layout::* in layout.
1 parent d0ab6e8 commit b2d52d2

File tree

5 files changed

+32
-32
lines changed

5 files changed

+32
-32
lines changed

src/librustc/ty/layout.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
pub use self::Integer::*;
12-
pub use self::Layout::*;
1312
pub use self::Primitive::*;
1413

1514
use session::{self, DataTypeKind, Session};
@@ -2015,10 +2014,10 @@ impl<'a, 'tcx> FullLayout<'tcx> {
20152014
};
20162015

20172016
let (layout, fields, abi) = match *self.layout {
2018-
Univariant => (self.layout, self.fields, self.abi),
2017+
Layout::Univariant => (self.layout, self.fields, self.abi),
20192018

2020-
NullablePointer { ref variants, .. } |
2021-
General { ref variants, .. } => {
2019+
Layout::NullablePointer { ref variants, .. } |
2020+
Layout::General { ref variants, .. } => {
20222021
let variant = &variants[variant_index];
20232022
(&variant.layout, &variant.fields, variant.abi)
20242023
}
@@ -2104,8 +2103,8 @@ impl<'a, 'tcx> FullLayout<'tcx> {
21042103
match self.variant_index {
21052104
None => match *self.layout {
21062105
// Discriminant field for enums (where applicable).
2107-
General { discr, .. } |
2108-
NullablePointer { discr, .. } => {
2106+
Layout::General { discr, .. } |
2107+
Layout::NullablePointer { discr, .. } => {
21092108
return [discr.to_ty(tcx)][i];
21102109
}
21112110
_ if def.variants.len() > 1 => return [][i],
@@ -2174,29 +2173,29 @@ impl<'a, 'tcx> FullLayout<'tcx> {
21742173
{
21752174
let tcx = cx.tcx();
21762175
match (self.layout, self.abi, &self.ty.sty) {
2177-
(&Scalar, Abi::Scalar(Pointer), _) if !self.ty.is_unsafe_ptr() => {
2176+
(&Layout::Scalar, Abi::Scalar(Pointer), _) if !self.ty.is_unsafe_ptr() => {
21782177
Ok(Some((Size::from_bytes(0), Pointer)))
21792178
}
2180-
(&General { discr, .. }, _, &ty::TyAdt(def, _)) => {
2179+
(&Layout::General { discr, .. }, _, &ty::TyAdt(def, _)) => {
21812180
if def.discriminants(tcx).all(|d| d.to_u128_unchecked() != 0) {
21822181
Ok(Some((self.fields.offset(0), discr)))
21832182
} else {
21842183
Ok(None)
21852184
}
21862185
}
21872186

2188-
(&FatPointer, _, _) if !self.ty.is_unsafe_ptr() => {
2187+
(&Layout::FatPointer, _, _) if !self.ty.is_unsafe_ptr() => {
21892188
Ok(Some((self.fields.offset(FAT_PTR_ADDR), Pointer)))
21902189
}
21912190

21922191
// Is this the NonZero lang item wrapping a pointer or integer type?
21932192
(_, _, &ty::TyAdt(def, _)) if Some(def.did) == tcx.lang_items().non_zero() => {
21942193
let field = self.field(cx, 0)?;
21952194
match (field.layout, field.abi) {
2196-
(&Scalar, Abi::Scalar(value)) => {
2195+
(&Layout::Scalar, Abi::Scalar(value)) => {
21972196
Ok(Some((self.fields.offset(0), value)))
21982197
}
2199-
(&FatPointer, _) => {
2198+
(&Layout::FatPointer, _) => {
22002199
Ok(Some((self.fields.offset(0) +
22012200
field.fields.offset(FAT_PTR_ADDR),
22022201
Pointer)))
@@ -2206,7 +2205,7 @@ impl<'a, 'tcx> FullLayout<'tcx> {
22062205
}
22072206

22082207
// Perhaps one of the fields is non-zero, let's recurse and find out.
2209-
(&Univariant, _, _) => {
2208+
(&Layout::Univariant, _, _) => {
22102209
for i in 0..self.fields.count() {
22112210
let r = self.field(cx, i)?.non_zero_field(cx)?;
22122211
if let Some((offset, primitive)) = r {

src/librustc_trans/abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ impl<'a, 'tcx> FnType<'tcx> {
766766
for ty in inputs.iter().chain(extra_args.iter()) {
767767
let mut arg = arg_of(ty, false);
768768

769-
if let ty::layout::FatPointer { .. } = *arg.layout.layout {
769+
if let ty::layout::Layout::FatPointer { .. } = *arg.layout.layout {
770770
let mut data = ArgType::new(arg.layout.field(ccx, 0));
771771
let mut info = ArgType::new(arg.layout.field(ccx, 1));
772772

src/librustc_trans/debuginfo/metadata.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
11301130
-> Vec<MemberDescription> {
11311131
let adt = &self.enum_type.ty_adt_def().unwrap();
11321132
match *self.type_rep.layout {
1133-
layout::General { ref variants, .. } => {
1133+
layout::Layout::General { ref variants, .. } => {
11341134
let discriminant_info = RegularDiscriminant(self.discriminant_type_metadata
11351135
.expect(""));
11361136
(0..variants.len()).map(|i| {
@@ -1159,7 +1159,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
11591159
}
11601160
}).collect()
11611161
},
1162-
layout::Univariant => {
1162+
layout::Layout::Univariant => {
11631163
assert!(adt.variants.len() <= 1);
11641164

11651165
if adt.variants.is_empty() {
@@ -1191,7 +1191,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
11911191
]
11921192
}
11931193
}
1194-
layout::NullablePointer {
1194+
layout::Layout::NullablePointer {
11951195
nndiscr,
11961196
discr,
11971197
..
@@ -1432,8 +1432,9 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
14321432
let type_rep = cx.layout_of(enum_type);
14331433

14341434
let discriminant_type_metadata = match *type_rep.layout {
1435-
layout::NullablePointer { .. } | layout::Univariant { .. } => None,
1436-
layout::General { discr, .. } => Some(discriminant_type_metadata(discr)),
1435+
layout::Layout::NullablePointer { .. } |
1436+
layout::Layout::Univariant { .. } => None,
1437+
layout::Layout::General { discr, .. } => Some(discriminant_type_metadata(discr)),
14371438
ref l @ _ => bug!("Not an enum layout: {:#?}", l)
14381439
};
14391440

src/librustc_trans/mir/constant.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ fn trans_const_adt<'a, 'tcx>(
10911091
_ => 0,
10921092
};
10931093
match *l.layout {
1094-
layout::General { .. } => {
1094+
layout::Layout::General { .. } => {
10951095
let discr = match *kind {
10961096
mir::AggregateKind::Adt(adt_def, _, _, _) => {
10971097
adt_def.discriminant_for_variant(ccx.tcx(), variant_index)
@@ -1108,7 +1108,7 @@ fn trans_const_adt<'a, 'tcx>(
11081108
build_const_struct(ccx, l.for_variant(variant_index), vals, Some(discr))
11091109
}
11101110
}
1111-
layout::UntaggedUnion => {
1111+
layout::Layout::UntaggedUnion => {
11121112
assert_eq!(variant_index, 0);
11131113
let contents = [
11141114
vals[0].llval,
@@ -1117,14 +1117,14 @@ fn trans_const_adt<'a, 'tcx>(
11171117

11181118
Const::new(C_struct(ccx, &contents, l.is_packed()), t)
11191119
}
1120-
layout::Univariant => {
1120+
layout::Layout::Univariant => {
11211121
assert_eq!(variant_index, 0);
11221122
build_const_struct(ccx, l, vals, None)
11231123
}
1124-
layout::Vector => {
1124+
layout::Layout::Vector => {
11251125
Const::new(C_vector(&vals.iter().map(|x| x.llval).collect::<Vec<_>>()), t)
11261126
}
1127-
layout::NullablePointer { nndiscr, .. } => {
1127+
layout::Layout::NullablePointer { nndiscr, .. } => {
11281128
if variant_index as u64 == nndiscr {
11291129
build_const_struct(ccx, l.for_variant(variant_index), vals, None)
11301130
} else {

src/librustc_trans/mir/lvalue.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ impl<'a, 'tcx> LvalueRef<'tcx> {
312312

313313
let cast_to = bcx.ccx.immediate_llvm_type_of(cast_to);
314314
match *l.layout {
315-
layout::Univariant { .. } |
316-
layout::UntaggedUnion { .. } => return C_uint(cast_to, 0),
315+
layout::Layout::Univariant { .. } |
316+
layout::Layout::UntaggedUnion { .. } => return C_uint(cast_to, 0),
317317
_ => {}
318318
}
319319

@@ -324,7 +324,7 @@ impl<'a, 'tcx> LvalueRef<'tcx> {
324324
_ => bug!("discriminant not scalar: {:#?}", discr_layout)
325325
};
326326
let (min, max) = match *l.layout {
327-
layout::General { ref discr_range, .. } => (discr_range.start, discr_range.end),
327+
layout::Layout::General { ref discr_range, .. } => (discr_range.start, discr_range.end),
328328
_ => (0, u64::max_value()),
329329
};
330330
let max_next = max.wrapping_add(1);
@@ -350,14 +350,14 @@ impl<'a, 'tcx> LvalueRef<'tcx> {
350350
}
351351
};
352352
match *l.layout {
353-
layout::General { .. } => {
353+
layout::Layout::General { .. } => {
354354
let signed = match discr_scalar {
355355
layout::Int(_, signed) => signed,
356356
_ => false
357357
};
358358
bcx.intcast(lldiscr, cast_to, signed)
359359
}
360-
layout::NullablePointer { nndiscr, .. } => {
360+
layout::Layout::NullablePointer { nndiscr, .. } => {
361361
let cmp = if nndiscr == 0 { llvm::IntEQ } else { llvm::IntNE };
362362
let zero = C_null(bcx.ccx.llvm_type_of(discr_layout.ty));
363363
bcx.intcast(bcx.icmp(cmp, lldiscr, zero), cast_to, false)
@@ -374,12 +374,12 @@ impl<'a, 'tcx> LvalueRef<'tcx> {
374374
.discriminant_for_variant(bcx.tcx(), variant_index)
375375
.to_u128_unchecked() as u64;
376376
match *l.layout {
377-
layout::General { .. } => {
377+
layout::Layout::General { .. } => {
378378
let ptr = self.project_field(bcx, 0);
379379
bcx.store(C_int(bcx.ccx.llvm_type_of(ptr.ty.to_ty(bcx.tcx())), to as i64),
380380
ptr.llval, ptr.alignment.non_abi());
381381
}
382-
layout::NullablePointer { nndiscr, .. } => {
382+
layout::Layout::NullablePointer { nndiscr, .. } => {
383383
if to != nndiscr {
384384
let use_memset = match l.abi {
385385
layout::Abi::Scalar(_) => false,
@@ -429,8 +429,8 @@ impl<'a, 'tcx> LvalueRef<'tcx> {
429429
// If this is an enum, cast to the appropriate variant struct type.
430430
let layout = bcx.ccx.layout_of(ty);
431431
match *layout.layout {
432-
layout::NullablePointer { .. } |
433-
layout::General { .. } => {
432+
layout::Layout::NullablePointer { .. } |
433+
layout::Layout::General { .. } => {
434434
let variant_layout = layout.for_variant(variant_index);
435435
let variant_ty = Type::struct_(bcx.ccx,
436436
&type_of::struct_llfields(bcx.ccx, variant_layout),

0 commit comments

Comments
 (0)