Skip to content

Commit 87ace0d

Browse files
committed
More snap cleanup
1 parent 0648517 commit 87ace0d

File tree

6 files changed

+13
-29
lines changed

6 files changed

+13
-29
lines changed

src/libcompiler_builtins/lib.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,7 @@ pub mod reimpls {
544544
const MD1 : u32 = MANTISSA_DIGITS + 1;
545545
const MD2 : u32 = MANTISSA_DIGITS + 2;
546546

547-
// SNAP: replace this with !0u128
548-
let negn :u128 = !0;
547+
let negn = !0u128;
549548

550549
if sd > MANTISSA_DIGITS {
551550
a = match sd {
@@ -579,8 +578,7 @@ pub mod reimpls {
579578
const MD1 : u32 = MANTISSA_DIGITS + 1;
580579
const MD2 : u32 = MANTISSA_DIGITS + 2;
581580

582-
// SNAP: replace this with !0u128
583-
let negn :u128 = !0;
581+
let negn = !0u128;
584582

585583
if sd > MANTISSA_DIGITS {
586584
a = match sd {

src/librustc_const_eval/eval.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -482,12 +482,9 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>,
482482
(&LitKind::Int(I64_OVERFLOW, Signed(IntTy::I64)), _) => {
483483
return Ok(Integral(I64(i64::min_value())))
484484
},
485-
(&LitKind::Int(n, _), Some(&ty::TyInt(IntTy::I128))) |
486-
(&LitKind::Int(n, Signed(IntTy::I128)), _) => {
487-
// SNAP: replace n in pattern with I128_OVERFLOW and remove this if.
488-
if n == I128_OVERFLOW {
489-
return Ok(Integral(I128(i128::min_value())))
490-
}
485+
(&LitKind::Int(I128_OVERFLOW, _), Some(&ty::TyInt(IntTy::I128))) |
486+
(&LitKind::Int(I128_OVERFLOW, Signed(IntTy::I128)), _) => {
487+
return Ok(Integral(I128(i128::min_value())))
491488
},
492489
(&LitKind::Int(n, _), Some(&ty::TyInt(IntTy::Is))) |
493490
(&LitKind::Int(n, Signed(IntTy::Is)), _) => {

src/librustc_const_math/int.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,11 @@ impl ConstInt {
155155
(InferSigned(a @ 0...ibounds::U8MAX), U8(_)) => U8(a as u8),
156156
(InferSigned(a @ 0...ibounds::U16MAX), U16(_)) => U16(a as u16),
157157
(InferSigned(a @ 0...ibounds::U32MAX), U32(_)) => U32(a as u32),
158-
// SNAP: replace with U64MAX
159-
(InferSigned(a @ 0...ibounds::I64MAX), U64(_)) => U64(a as u64),
158+
(InferSigned(a @ 0...ibounds::U64MAX), U64(_)) => U64(a as u64),
160159
(InferSigned(a @ 0...ibounds::I128MAX), U128(_)) => U128(a as u128),
161160
(InferSigned(a @ 0...ibounds::U16MAX), Usize(Us16(_))) => Usize(Us16(a as u16)),
162161
(InferSigned(a @ 0...ibounds::U32MAX), Usize(Us32(_))) => Usize(Us32(a as u32)),
163-
// SNAP: replace with U64MAX
164-
(InferSigned(a @ 0...ibounds::I64MAX), Usize(Us64(_))) => Usize(Us64(a as u64)),
162+
(InferSigned(a @ 0...ibounds::U64MAX), Usize(Us64(_))) => Usize(Us64(a as u64)),
165163
(InferSigned(_), _) => return Err(ConstMathErr::NotInRange),
166164
_ => self, // already known types
167165
};

src/librustc_trans/common.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,10 @@ pub fn C_integral(t: Type, u: u64, sign_extend: bool) -> ValueRef {
229229
}
230230
}
231231

232-
pub fn C_big_integral(t: Type, u: u128, sign_extend: bool) -> ValueRef {
233-
if ::std::mem::size_of::<u128>() == 16 {
234-
unsafe {
235-
let words = [u as u64, u.wrapping_shr(64) as u64];
236-
llvm::LLVMConstIntOfArbitraryPrecision(t.to_ref(), 2, words.as_ptr())
237-
}
238-
} else {
239-
// SNAP: remove after snapshot
240-
C_integral(t, u as u64, sign_extend)
232+
pub fn C_big_integral(t: Type, u: u128) -> ValueRef {
233+
unsafe {
234+
let words = [u as u64, u.wrapping_shr(64) as u64];
235+
llvm::LLVMConstIntOfArbitraryPrecision(t.to_ref(), 2, words.as_ptr())
241236
}
242237
}
243238

src/librustc_trans/mir/constant.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<'tcx> Const<'tcx> {
7575
ConstVal::Integral(I16(v)) => C_integral(Type::i16(ccx), v as u64, true),
7676
ConstVal::Integral(I32(v)) => C_integral(Type::i32(ccx), v as u64, true),
7777
ConstVal::Integral(I64(v)) => C_integral(Type::i64(ccx), v as u64, true),
78-
ConstVal::Integral(I128(v)) => C_big_integral(Type::i128(ccx), v as u128, true),
78+
ConstVal::Integral(I128(v)) => C_big_integral(Type::i128(ccx), v as u128),
7979
ConstVal::Integral(Isize(v)) => {
8080
let i = v.as_i64(ccx.tcx().sess.target.int_type);
8181
C_integral(Type::int(ccx), i as u64, true)
@@ -84,7 +84,7 @@ impl<'tcx> Const<'tcx> {
8484
ConstVal::Integral(U16(v)) => C_integral(Type::i16(ccx), v as u64, false),
8585
ConstVal::Integral(U32(v)) => C_integral(Type::i32(ccx), v as u64, false),
8686
ConstVal::Integral(U64(v)) => C_integral(Type::i64(ccx), v, false),
87-
ConstVal::Integral(U128(v)) => C_big_integral(Type::i128(ccx), v, false),
87+
ConstVal::Integral(U128(v)) => C_big_integral(Type::i128(ccx), v),
8888
ConstVal::Integral(Usize(v)) => {
8989
let u = v.as_u64(ccx.tcx().sess.target.uint_type);
9090
C_integral(Type::int(ccx), u, false)

src/test/run-pass/issue-38987.rs

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
// except according to those terms.
1010
#![feature(i128_type)]
1111

12-
// SNAP: run on all stages after snapshot, i128 currently doesn't work on stages 0 and 1
13-
// ignore-stage1
14-
// ignore-stage0
15-
1612
fn main() {
1713
let _ = -0x8000_0000_0000_0000_0000_0000_0000_0000i128;
1814
}

0 commit comments

Comments
 (0)