diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 33902fe913a9c..d5cde7034116c 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -524,7 +524,7 @@ impl DepGraph { edge_list_indices.push((start, end)); } - debug_assert!(edge_list_data.len() <= ::std::u32::MAX as usize); + debug_assert!(edge_list_data.len() <= u32::MAX as usize); debug_assert_eq!(edge_list_data.len(), total_edge_count); SerializedDepGraph { nodes, fingerprints, edge_list_indices, edge_list_data } diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs index d3efe62e8c153..c8d35db0adeb2 100644 --- a/src/librustc/mir/interpret/allocation.rs +++ b/src/librustc/mir/interpret/allocation.rs @@ -818,9 +818,9 @@ impl UndefMask { // First set all bits except the first `bita`, // then unset the last `64 - bitb` bits. let range = if bitb == 0 { - u64::max_value() << bita + u64::MAX << bita } else { - (u64::max_value() << bita) & (u64::max_value() >> (64 - bitb)) + (u64::MAX << bita) & (u64::MAX >> (64 - bitb)) }; if new_state { self.blocks[blocka] |= range; @@ -832,21 +832,21 @@ impl UndefMask { // across block boundaries if new_state { // Set `bita..64` to `1`. - self.blocks[blocka] |= u64::max_value() << bita; + self.blocks[blocka] |= u64::MAX << bita; // Set `0..bitb` to `1`. if bitb != 0 { - self.blocks[blockb] |= u64::max_value() >> (64 - bitb); + self.blocks[blockb] |= u64::MAX >> (64 - bitb); } // Fill in all the other blocks (much faster than one bit at a time). for block in (blocka + 1)..blockb { - self.blocks[block] = u64::max_value(); + self.blocks[block] = u64::MAX; } } else { // Set `bita..64` to `0`. - self.blocks[blocka] &= !(u64::max_value() << bita); + self.blocks[blocka] &= !(u64::MAX << bita); // Set `0..bitb` to `0`. if bitb != 0 { - self.blocks[blockb] &= !(u64::max_value() >> (64 - bitb)); + self.blocks[blockb] &= !(u64::MAX >> (64 - bitb)); } // Fill in all the other blocks (much faster than one bit at a time). for block in (blocka + 1)..blockb { diff --git a/src/librustc/mir/interpret/pointer.rs b/src/librustc/mir/interpret/pointer.rs index a4974fb541b6b..cc3c50b7899f3 100644 --- a/src/librustc/mir/interpret/pointer.rs +++ b/src/librustc/mir/interpret/pointer.rs @@ -78,9 +78,9 @@ pub trait PointerArithmetic: layout::HasDataLayout { fn overflowing_signed_offset(&self, val: u64, i: i128) -> (u64, bool) { // FIXME: is it possible to over/underflow here? if i < 0 { - // Trickery to ensure that `i64::min_value()` works fine: compute `n = -i`. + // Trickery to ensure that `i64::MIN` works fine: compute `n = -i`. // This formula only works for true negative values; it overflows for zero! - let n = u64::max_value() - (i as u64) + 1; + let n = u64::MAX - (i as u64) + 1; let res = val.overflowing_sub(n); self.truncate_to_ptr(res) } else { diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index f1b4b828c71fa..7a5a417919d50 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -7,7 +7,6 @@ use rustc_span::DUMMY_SP; use std::cmp; use std::fmt; -use std::i128; use std::iter; use std::mem; use std::ops::Bound; @@ -1001,7 +1000,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { } } - let (mut min, mut max) = (i128::max_value(), i128::min_value()); + let (mut min, mut max) = (i128::MAX, i128::MIN); let discr_type = def.repr.discr_type(); let bits = Integer::from_attr(self, discr_type).size().bits(); for (i, discr) in def.discriminants(tcx) { @@ -1021,7 +1020,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { } } // We might have no inhabited variants, so pretend there's at least one. - if (min, max) == (i128::max_value(), i128::min_value()) { + if (min, max) == (i128::MAX, i128::MIN) { min = 0; max = 0; } diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index 3bf92552c8624..4829955cb70c4 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -920,7 +920,7 @@ pub trait PrettyPrinter<'tcx>: } (ConstValue::Scalar(Scalar::Raw { data, .. }), ty::Uint(ui)) => { let bit_size = Integer::from_attr(&self.tcx(), UnsignedInt(*ui)).size(); - let max = truncate(u128::max_value(), bit_size); + let max = truncate(u128::MAX, bit_size); let ui_str = ui.name_str(); if data == max { diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index 109ac97fe6265..5e36e4df698ed 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -92,7 +92,7 @@ struct AbsoluteBytePos(u32); impl AbsoluteBytePos { fn new(pos: usize) -> AbsoluteBytePos { - debug_assert!(pos <= ::std::u32::MAX as usize); + debug_assert!(pos <= u32::MAX as usize); AbsoluteBytePos(pos as u32) } diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 87dcc617fa289..fcebedb2601c2 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -50,11 +50,11 @@ fn signed_min(size: Size) -> i128 { } fn signed_max(size: Size) -> i128 { - i128::max_value() >> (128 - size.bits()) + i128::MAX >> (128 - size.bits()) } fn unsigned_max(size: Size) -> u128 { - u128::max_value() >> (128 - size.bits()) + u128::MAX >> (128 - size.bits()) } fn int_size_and_signed<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> (Size, bool) { @@ -77,7 +77,7 @@ impl<'tcx> Discr<'tcx> { let min = signed_min(size); let max = signed_max(size); let val = sign_extend(self.val, size) as i128; - assert!(n < (i128::max_value() as u128)); + assert!(n < (i128::MAX as u128)); let n = n as i128; let oflo = val > max - n; let val = if oflo { min + (n - (max - val) - 1) } else { val + n }; diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index 25463f31867df..b4e33b9502e69 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -16,7 +16,6 @@ use std::borrow::Borrow; use std::fmt; use std::io; use std::path::PathBuf; -use std::usize; pub use self::at_location::{FlowAtLocation, FlowsAtLocation}; pub(crate) use self::drop_flag_effects::*; diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs index d63abdc356234..891afbf437f2b 100644 --- a/src/librustc_mir/interpret/intrinsics.rs +++ b/src/librustc_mir/interpret/intrinsics.rs @@ -203,7 +203,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { if is_add { // max unsigned Scalar::from_uint( - u128::max_value() >> (128 - num_bits), + u128::MAX >> (128 - num_bits), Size::from_bits(num_bits), ) } else { @@ -381,11 +381,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { dest: PlaceTy<'tcx, M::PointerTag>, ) -> InterpResult<'tcx> { // Performs an exact division, resulting in undefined behavior where - // `x % y != 0` or `y == 0` or `x == T::min_value() && y == -1`. + // `x % y != 0` or `y == 0` or `x == T::MIN && y == -1`. // First, check x % y != 0 (or if that computation overflows). let (res, overflow, _ty) = self.overflowing_binary_op(BinOp::Rem, a, b)?; if overflow || res.assert_bits(a.layout.size) != 0 { - // Then, check if `b` is -1, which is the "min_value / -1" case. + // Then, check if `b` is -1, which is the "MIN / -1" case. let minus1 = Scalar::from_int(-1, dest.layout.size); let b_scalar = b.to_scalar().unwrap(); if b_scalar == minus1 { diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs index 731dcc6a25f14..4f99bfe8a852a 100644 --- a/src/librustc_mir/interpret/validity.rs +++ b/src/librustc_mir/interpret/validity.rs @@ -463,7 +463,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, 'tcx, M let (lo, hi) = valid_range.clone().into_inner(); // Determine the allowed range // `max_hi` is as big as the size fits - let max_hi = u128::max_value() >> (128 - op.layout.size.bits()); + let max_hi = u128::MAX >> (128 - op.layout.size.bits()); assert!(hi <= max_hi); // We could also write `(hi + 1) % (max_hi + 1) == lo` but `max_hi + 1` overflows for `u128` if (lo == 0 && hi == max_hi) || (hi + 1 == lo) {