Skip to content

Commit 6c19104

Browse files
committed
Fix build
Additionally, revert unnecessary changes to ty::layout
1 parent eb727a8 commit 6c19104

File tree

1 file changed

+10
-29
lines changed

1 file changed

+10
-29
lines changed

src/librustc/ty/layout.rs

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -382,25 +382,8 @@ impl Integer {
382382
}
383383
}
384384

385-
pub fn to_attr(&self, signed: bool) -> attr::IntType {
386-
match (*self, signed) {
387-
(I1, false) => attr::IntType::UnsignedInt(UintTy::U8),
388-
(I8, false) => attr::IntType::UnsignedInt(UintTy::U8),
389-
(I16, false) => attr::IntType::UnsignedInt(UintTy::U16),
390-
(I32, false) => attr::IntType::UnsignedInt(UintTy::U32),
391-
(I64, false) => attr::IntType::UnsignedInt(UintTy::U64),
392-
(I128, false) => attr::IntType::UnsignedInt(UintTy::U128),
393-
(I1, true) => attr::IntType::SignedInt(IntTy::I8),
394-
(I8, true) => attr::IntType::SignedInt(IntTy::I8),
395-
(I16, true) => attr::IntType::SignedInt(IntTy::I16),
396-
(I32, true) => attr::IntType::SignedInt(IntTy::I32),
397-
(I64, true) => attr::IntType::SignedInt(IntTy::I64),
398-
(I128, true) => attr::IntType::SignedInt(IntTy::I128),
399-
}
400-
}
401-
402385
/// Find the smallest Integer type which can represent the signed value.
403-
pub fn fit_signed(x: i128) -> Integer {
386+
pub fn fit_signed(x: i64) -> Integer {
404387
match x {
405388
-0x0000_0000_0000_0001...0x0000_0000_0000_0000 => I1,
406389
-0x0000_0000_0000_0080...0x0000_0000_0000_007f => I8,
@@ -412,7 +395,7 @@ impl Integer {
412395
}
413396

414397
/// Find the smallest Integer type which can represent the unsigned value.
415-
pub fn fit_unsigned(x: u128) -> Integer {
398+
pub fn fit_unsigned(x: u64) -> Integer {
416399
match x {
417400
0...0x0000_0000_0000_0001 => I1,
418401
0...0x0000_0000_0000_00ff => I8,
@@ -453,13 +436,13 @@ impl Integer {
453436
/// signed discriminant range and #[repr] attribute.
454437
/// N.B.: u64 values above i64::MAX will be treated as signed, but
455438
/// that shouldn't affect anything, other than maybe debuginfo.
456-
pub fn repr_discr(tcx: TyCtxt, ty: Ty, repr: &ReprOptions, min: i128, max: i128)
439+
fn repr_discr(tcx: TyCtxt, ty: Ty, repr: &ReprOptions, min: i64, max: i64)
457440
-> (Integer, bool) {
458441
// Theoretically, negative values could be larger in unsigned representation
459442
// than the unsigned representation of the signed minimum. However, if there
460443
// are any negative values, the only valid unsigned representation is u64
461444
// which can fit all i64 values, so the result remains unaffected.
462-
let unsigned_fit = Integer::fit_unsigned(cmp::max(min as u128, max as u128));
445+
let unsigned_fit = Integer::fit_unsigned(cmp::max(min as u64, max as u64));
463446
let signed_fit = cmp::max(Integer::fit_signed(min), Integer::fit_signed(max));
464447

465448
let mut min_from_extern = None;
@@ -487,6 +470,7 @@ impl Integer {
487470
}
488471

489472
let at_least = min_from_extern.unwrap_or(min_default);
473+
490474
// If there are no negative values, we can use the unsigned fit.
491475
if min >= 0 {
492476
(cmp::max(unsigned_fit, at_least), false)
@@ -1198,21 +1182,17 @@ impl<'a, 'gcx, 'tcx> Layout {
11981182
i64::min_value(),
11991183
true);
12001184
for v in &def.variants {
1201-
let x = match def.discr_ty {
1202-
attr::IntType::SignedInt(IntTy::I128) |
1203-
attr::IntType::UnsignedInt(UintTy::U128) =>
1204-
bug!("128-bit discriminants not yet supported"),
1205-
attr::IntType::SignedInt(_) => v.disr_val as i64,
1206-
attr::IntType::UnsignedInt(_) => v.disr_val as u64 as i64,
1207-
};
1185+
let x = v.disr_val as i128 as i64;
12081186
if x == 0 { non_zero = false; }
12091187
if x < min { min = x; }
12101188
if x > max { max = x; }
12111189
}
12121190

12131191
// FIXME: should handle i128? signed-value based impl is weird and hard to
12141192
// grok.
1215-
let (discr, signed) = Integer::repr_discr(tcx, ty, hints, min, max);
1193+
let (discr, signed) = Integer::repr_discr(tcx, ty, &hints[..],
1194+
min,
1195+
max);
12161196
return success(CEnum {
12171197
discr: discr,
12181198
signed: signed,
@@ -1330,6 +1310,7 @@ impl<'a, 'gcx, 'tcx> Layout {
13301310
let discr_max = (variants.len() - 1) as i64;
13311311
assert!(discr_max >= 0);
13321312
let (min_ity, _) = Integer::repr_discr(tcx, ty, &hints[..], 0, discr_max);
1313+
13331314
let mut align = dl.aggregate_align;
13341315
let mut size = Size::from_bytes(0);
13351316

0 commit comments

Comments
 (0)