From c0ec0a27b3ed532c0ce58a2ad2f4dcd3d939210a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Fri, 27 Mar 2020 22:15:02 +0100 Subject: [PATCH] Replace max/min_value() with MAX/MIN assoc consts --- src/liballoc/slice.rs | 2 +- src/liballoc/str.rs | 2 +- src/libcore/fmt/mod.rs | 2 +- src/libcore/intrinsics.rs | 12 ++++++------ src/libcore/iter/traits/iterator.rs | 2 +- src/libcore/ptr/const_ptr.rs | 4 ++-- src/libcore/ptr/mut_ptr.rs | 4 ++-- src/librustc_target/abi/mod.rs | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index d8fc1faca3a..2ce5bc8ed2f 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -432,7 +432,7 @@ impl [T] { /// /// ```should_panic /// // this will panic at runtime - /// b"0123456789abcdef".repeat(usize::max_value()); + /// b"0123456789abcdef".repeat(usize::MAX); /// ``` #[stable(feature = "repeat_generic_slice", since = "1.40.0")] pub fn repeat(&self, n: usize) -> Vec diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index 843a2f1f8e9..70860c09a2c 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -499,7 +499,7 @@ impl str { /// /// ```should_panic /// // this will panic at runtime - /// "0123456789abcdef".repeat(usize::max_value()); + /// "0123456789abcdef".repeat(usize::MAX); /// ``` #[stable(feature = "repeat_str", since = "1.16.0")] pub fn repeat(&self, n: usize) -> String { diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index fe728d42c76..95411b525d0 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -852,7 +852,7 @@ pub trait LowerHex { /// } /// } /// -/// let l = Length(i32::max_value()); +/// let l = Length(i32::MAX); /// /// assert_eq!(format!("l as hex is: {:X}", l), "l as hex is: 7FFFFFFF"); /// diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 7e9140faa64..4a11fb39389 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -1739,11 +1739,11 @@ extern "rust-intrinsic" { pub fn mul_with_overflow(x: T, y: T) -> (T, bool); /// 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` pub fn exact_div(x: T, y: T) -> T; /// Performs an unchecked division, resulting in undefined behavior - /// where y = 0 or x = `T::min_value()` and y = -1 + /// where y = 0 or x = `T::MIN` and y = -1 /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `checked_div` method. For example, @@ -1751,7 +1751,7 @@ extern "rust-intrinsic" { #[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")] pub fn unchecked_div(x: T, y: T) -> T; /// Returns the remainder of an unchecked division, resulting in - /// undefined behavior where y = 0 or x = `T::min_value()` and y = -1 + /// undefined behavior where y = 0 or x = `T::MIN` and y = -1 /// /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `checked_rem` method. For example, @@ -1777,17 +1777,17 @@ extern "rust-intrinsic" { pub fn unchecked_shr(x: T, y: T) -> T; /// Returns the result of an unchecked addition, resulting in - /// undefined behavior when `x + y > T::max_value()` or `x + y < T::min_value()`. + /// undefined behavior when `x + y > T::MAX` or `x + y < T::MIN`. #[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")] pub fn unchecked_add(x: T, y: T) -> T; /// Returns the result of an unchecked subtraction, resulting in - /// undefined behavior when `x - y > T::max_value()` or `x - y < T::min_value()`. + /// undefined behavior when `x - y > T::MAX` or `x - y < T::MIN`. #[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")] pub fn unchecked_sub(x: T, y: T) -> T; /// Returns the result of an unchecked multiplication, resulting in - /// undefined behavior when `x * y > T::max_value()` or `x * y < T::min_value()`. + /// undefined behavior when `x * y > T::MAX` or `x * y < T::MIN`. #[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")] pub fn unchecked_mul(x: T, y: T) -> T; diff --git a/src/libcore/iter/traits/iterator.rs b/src/libcore/iter/traits/iterator.rs index daa880e7cd5..0c9318ab8e7 100644 --- a/src/libcore/iter/traits/iterator.rs +++ b/src/libcore/iter/traits/iterator.rs @@ -198,7 +198,7 @@ pub trait Iterator { /// // and the maximum possible lower bound /// let iter = 0..; /// - /// assert_eq!((usize::max_value(), None), iter.size_hint()); + /// assert_eq!((usize::MAX, None), iter.size_hint()); /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/ptr/const_ptr.rs b/src/libcore/ptr/const_ptr.rs index a540016854d..52e224d2a02 100644 --- a/src/libcore/ptr/const_ptr.rs +++ b/src/libcore/ptr/const_ptr.rs @@ -659,8 +659,8 @@ impl *const T { /// `align`. /// /// If it is not possible to align the pointer, the implementation returns - /// `usize::max_value()`. It is permissible for the implementation to *always* - /// return `usize::max_value()`. Only your algorithm's performance can depend + /// `usize::MAX`. It is permissible for the implementation to *always* + /// return `usize::MAX`. Only your algorithm's performance can depend /// on getting a usable offset here, not its correctness. /// /// The offset is expressed in number of `T` elements, and not bytes. The value returned can be diff --git a/src/libcore/ptr/mut_ptr.rs b/src/libcore/ptr/mut_ptr.rs index 01d830ca186..9f85d781d69 100644 --- a/src/libcore/ptr/mut_ptr.rs +++ b/src/libcore/ptr/mut_ptr.rs @@ -847,8 +847,8 @@ impl *mut T { /// `align`. /// /// If it is not possible to align the pointer, the implementation returns - /// `usize::max_value()`. It is permissible for the implementation to *always* - /// return `usize::max_value()`. Only your algorithm's performance can depend + /// `usize::MAX`. It is permissible for the implementation to *always* + /// return `usize::MAX`. Only your algorithm's performance can depend /// on getting a usable offset here, not its correctness. /// /// The offset is expressed in number of `T` elements, and not bytes. The value returned can be diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index f382ef984be..4c25363a657 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -577,7 +577,7 @@ pub struct Scalar { pub value: Primitive, /// Inclusive wrap-around range of valid values, that is, if - /// start > end, it represents `start..=max_value()`, + /// start > end, it represents `start..=MAX`, /// followed by `0..=end`. /// /// That is, for an i8 primitive, a range of `254..=2` means following