Skip to content

Commit c0ec0a2

Browse files
committed
Replace max/min_value() with MAX/MIN assoc consts
1 parent e9ce036 commit c0ec0a2

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

src/liballoc/slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ impl<T> [T] {
432432
///
433433
/// ```should_panic
434434
/// // this will panic at runtime
435-
/// b"0123456789abcdef".repeat(usize::max_value());
435+
/// b"0123456789abcdef".repeat(usize::MAX);
436436
/// ```
437437
#[stable(feature = "repeat_generic_slice", since = "1.40.0")]
438438
pub fn repeat(&self, n: usize) -> Vec<T>

src/liballoc/str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ impl str {
499499
///
500500
/// ```should_panic
501501
/// // this will panic at runtime
502-
/// "0123456789abcdef".repeat(usize::max_value());
502+
/// "0123456789abcdef".repeat(usize::MAX);
503503
/// ```
504504
#[stable(feature = "repeat_str", since = "1.16.0")]
505505
pub fn repeat(&self, n: usize) -> String {

src/libcore/fmt/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ pub trait LowerHex {
852852
/// }
853853
/// }
854854
///
855-
/// let l = Length(i32::max_value());
855+
/// let l = Length(i32::MAX);
856856
///
857857
/// assert_eq!(format!("l as hex is: {:X}", l), "l as hex is: 7FFFFFFF");
858858
///

src/libcore/intrinsics.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1739,19 +1739,19 @@ extern "rust-intrinsic" {
17391739
pub fn mul_with_overflow<T: Copy>(x: T, y: T) -> (T, bool);
17401740

17411741
/// Performs an exact division, resulting in undefined behavior where
1742-
/// `x % y != 0` or `y == 0` or `x == T::min_value() && y == -1`
1742+
/// `x % y != 0` or `y == 0` or `x == T::MIN && y == -1`
17431743
pub fn exact_div<T: Copy>(x: T, y: T) -> T;
17441744

17451745
/// Performs an unchecked division, resulting in undefined behavior
1746-
/// where y = 0 or x = `T::min_value()` and y = -1
1746+
/// where y = 0 or x = `T::MIN` and y = -1
17471747
///
17481748
/// The stabilized versions of this intrinsic are available on the integer
17491749
/// primitives via the `checked_div` method. For example,
17501750
/// [`std::u32::checked_div`](../../std/primitive.u32.html#method.checked_div)
17511751
#[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")]
17521752
pub fn unchecked_div<T: Copy>(x: T, y: T) -> T;
17531753
/// Returns the remainder of an unchecked division, resulting in
1754-
/// undefined behavior where y = 0 or x = `T::min_value()` and y = -1
1754+
/// undefined behavior where y = 0 or x = `T::MIN` and y = -1
17551755
///
17561756
/// The stabilized versions of this intrinsic are available on the integer
17571757
/// primitives via the `checked_rem` method. For example,
@@ -1777,17 +1777,17 @@ extern "rust-intrinsic" {
17771777
pub fn unchecked_shr<T: Copy>(x: T, y: T) -> T;
17781778

17791779
/// Returns the result of an unchecked addition, resulting in
1780-
/// undefined behavior when `x + y > T::max_value()` or `x + y < T::min_value()`.
1780+
/// undefined behavior when `x + y > T::MAX` or `x + y < T::MIN`.
17811781
#[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")]
17821782
pub fn unchecked_add<T: Copy>(x: T, y: T) -> T;
17831783

17841784
/// Returns the result of an unchecked subtraction, resulting in
1785-
/// undefined behavior when `x - y > T::max_value()` or `x - y < T::min_value()`.
1785+
/// undefined behavior when `x - y > T::MAX` or `x - y < T::MIN`.
17861786
#[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")]
17871787
pub fn unchecked_sub<T: Copy>(x: T, y: T) -> T;
17881788

17891789
/// Returns the result of an unchecked multiplication, resulting in
1790-
/// undefined behavior when `x * y > T::max_value()` or `x * y < T::min_value()`.
1790+
/// undefined behavior when `x * y > T::MAX` or `x * y < T::MIN`.
17911791
#[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")]
17921792
pub fn unchecked_mul<T: Copy>(x: T, y: T) -> T;
17931793

src/libcore/iter/traits/iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub trait Iterator {
198198
/// // and the maximum possible lower bound
199199
/// let iter = 0..;
200200
///
201-
/// assert_eq!((usize::max_value(), None), iter.size_hint());
201+
/// assert_eq!((usize::MAX, None), iter.size_hint());
202202
/// ```
203203
#[inline]
204204
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/ptr/const_ptr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,8 @@ impl<T: ?Sized> *const T {
659659
/// `align`.
660660
///
661661
/// If it is not possible to align the pointer, the implementation returns
662-
/// `usize::max_value()`. It is permissible for the implementation to *always*
663-
/// return `usize::max_value()`. Only your algorithm's performance can depend
662+
/// `usize::MAX`. It is permissible for the implementation to *always*
663+
/// return `usize::MAX`. Only your algorithm's performance can depend
664664
/// on getting a usable offset here, not its correctness.
665665
///
666666
/// The offset is expressed in number of `T` elements, and not bytes. The value returned can be

src/libcore/ptr/mut_ptr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,8 @@ impl<T: ?Sized> *mut T {
847847
/// `align`.
848848
///
849849
/// If it is not possible to align the pointer, the implementation returns
850-
/// `usize::max_value()`. It is permissible for the implementation to *always*
851-
/// return `usize::max_value()`. Only your algorithm's performance can depend
850+
/// `usize::MAX`. It is permissible for the implementation to *always*
851+
/// return `usize::MAX`. Only your algorithm's performance can depend
852852
/// on getting a usable offset here, not its correctness.
853853
///
854854
/// The offset is expressed in number of `T` elements, and not bytes. The value returned can be

src/librustc_target/abi/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ pub struct Scalar {
577577
pub value: Primitive,
578578

579579
/// Inclusive wrap-around range of valid values, that is, if
580-
/// start > end, it represents `start..=max_value()`,
580+
/// start > end, it represents `start..=MAX`,
581581
/// followed by `0..=end`.
582582
///
583583
/// That is, for an i8 primitive, a range of `254..=2` means following

0 commit comments

Comments
 (0)