From f5e0f4d783a492eba594a45795537adbbe9e202e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= <faern@faern.net>
Date: Tue, 17 Dec 2019 00:28:16 +0100
Subject: [PATCH 01/15] Deprecate min_value() and max_value() for all integers

---
 src/libcore/num/mod.rs | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index b6b4a46e0b812..edeacf7d65249 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -256,6 +256,7 @@ Basic usage:
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[rustc_deprecated(since = "1.41.0", reason = "replaced by associated constant MIN")]
             #[inline(always)]
             #[rustc_promotable]
             #[rustc_const_stable(feature = "const_min_value", since = "1.32.0")]
@@ -276,6 +277,7 @@ Basic usage:
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[rustc_deprecated(since = "1.41.0", reason = "replaced by associated constant MAX")]
             #[inline(always)]
             #[rustc_promotable]
             #[rustc_const_stable(feature = "const_max_value", since = "1.32.0")]

From 5450cc7f04f204647855a6877a69dd14132ca987 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= <faern@faern.net>
Date: Tue, 17 Dec 2019 00:29:16 +0100
Subject: [PATCH 02/15] Deprecate MIN/MAX constants in integer modules

---
 src/libcore/num/int_macros.rs  | 2 ++
 src/libcore/num/uint_macros.rs | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/src/libcore/num/int_macros.rs b/src/libcore/num/int_macros.rs
index 5c59fe25f6483..a2aa80982cbe9 100644
--- a/src/libcore/num/int_macros.rs
+++ b/src/libcore/num/int_macros.rs
@@ -5,9 +5,11 @@ macro_rules! int_module {
     ($T:ident, #[$attr:meta]) => (
         /// The smallest value that can be represented by this integer type.
         #[$attr]
+        #[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant MIN")]
         pub const MIN: $T = $T::min_value();
         /// The largest value that can be represented by this integer type.
         #[$attr]
+        #[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant MAX")]
         pub const MAX: $T = $T::max_value();
     )
 }
diff --git a/src/libcore/num/uint_macros.rs b/src/libcore/num/uint_macros.rs
index a94b541ddb907..da1300d2a92d7 100644
--- a/src/libcore/num/uint_macros.rs
+++ b/src/libcore/num/uint_macros.rs
@@ -5,9 +5,11 @@ macro_rules! uint_module {
     ($T:ident, #[$attr:meta]) => (
         /// The smallest value that can be represented by this integer type.
         #[$attr]
+        #[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant MIN")]
         pub const MIN: $T = $T::min_value();
         /// The largest value that can be represented by this integer type.
         #[$attr]
+        #[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant MAX")]
         pub const MAX: $T = $T::max_value();
     )
 }

From 3afdf3f94694c6e967928fe9a94365ccd616887f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= <faern@faern.net>
Date: Tue, 17 Dec 2019 00:29:37 +0100
Subject: [PATCH 03/15] Deprecate all integer modules

---
 src/libcore/lib.rs | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index 6f1d69821f56c..cc085f0c1615a 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -154,29 +154,41 @@ mod int_macros;
 #[macro_use]
 mod uint_macros;
 
+#[rustc_deprecated(since = "1.42.0", reason = "Replaced by associated constants")]
 #[path = "num/i128.rs"]
 pub mod i128;
+#[rustc_deprecated(since = "1.42.0", reason = "Replaced by associated constants")]
 #[path = "num/i16.rs"]
 pub mod i16;
+#[rustc_deprecated(since = "1.42.0", reason = "Replaced by associated constants")]
 #[path = "num/i32.rs"]
 pub mod i32;
+#[rustc_deprecated(since = "1.42.0", reason = "Replaced by associated constants")]
 #[path = "num/i64.rs"]
 pub mod i64;
+#[rustc_deprecated(since = "1.42.0", reason = "Replaced by associated constants")]
 #[path = "num/i8.rs"]
 pub mod i8;
+#[rustc_deprecated(since = "1.42.0", reason = "Replaced by associated constants")]
 #[path = "num/isize.rs"]
 pub mod isize;
 
+#[rustc_deprecated(since = "1.42.0", reason = "Replaced by associated constants")]
 #[path = "num/u128.rs"]
 pub mod u128;
+#[rustc_deprecated(since = "1.42.0", reason = "Replaced by associated constants")]
 #[path = "num/u16.rs"]
 pub mod u16;
+#[rustc_deprecated(since = "1.42.0", reason = "Replaced by associated constants")]
 #[path = "num/u32.rs"]
 pub mod u32;
+#[rustc_deprecated(since = "1.42.0", reason = "Replaced by associated constants")]
 #[path = "num/u64.rs"]
 pub mod u64;
+#[rustc_deprecated(since = "1.42.0", reason = "Replaced by associated constants")]
 #[path = "num/u8.rs"]
 pub mod u8;
+#[rustc_deprecated(since = "1.42.0", reason = "Replaced by associated constants")]
 #[path = "num/usize.rs"]
 pub mod usize;
 

From 8fbd3ad8b0891fe937eda7dcdc44cb911abb067a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= <faern@faern.net>
Date: Tue, 17 Dec 2019 00:42:28 +0100
Subject: [PATCH 04/15] Add MIN/MAX associated constants to all integer types

---
 src/libcore/num/mod.rs | 74 ++++++++++++++++++++++++++++--------------
 1 file changed, 50 insertions(+), 24 deletions(-)

diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index edeacf7d65249..9a26385fb255d 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -245,44 +245,56 @@ macro_rules! int_impl {
      $reversed:expr, $le_bytes:expr, $be_bytes:expr,
      $to_xe_bytes_doc:expr, $from_xe_bytes_doc:expr) => {
         doc_comment! {
-            concat!("Returns the smallest value that can be represented by this integer type.
+            concat!("The smallest value that can be represented by this integer type.
 
 # Examples
 
 Basic usage:
 
 ```
-", $Feature, "assert_eq!(", stringify!($SelfT), "::min_value(), ", stringify!($Min), ");",
+", $Feature, "assert_eq!(", stringify!($SelfT), "::MIN, ", stringify!($Min), ");",
 $EndFeature, "
 ```"),
-            #[stable(feature = "rust1", since = "1.0.0")]
-            #[rustc_deprecated(since = "1.41.0", reason = "replaced by associated constant MIN")]
-            #[inline(always)]
-            #[rustc_promotable]
-            #[rustc_const_stable(feature = "const_min_value", since = "1.32.0")]
-            pub const fn min_value() -> Self {
-                !0 ^ ((!0 as $UnsignedT) >> 1) as Self
-            }
+            #[stable(feature = "assoc_int_consts", since = "1.41.0")]
+            pub const MIN: Self = !0 ^ ((!0 as $UnsignedT) >> 1) as Self;
         }
 
         doc_comment! {
-            concat!("Returns the largest value that can be represented by this integer type.
+            concat!("The largest value that can be represented by this integer type.
 
 # Examples
 
 Basic usage:
 
 ```
-", $Feature, "assert_eq!(", stringify!($SelfT), "::max_value(), ", stringify!($Max), ");",
+", $Feature, "assert_eq!(", stringify!($SelfT), "::MAX, ", stringify!($Max), ");",
 $EndFeature, "
 ```"),
+            #[stable(feature = "assoc_int_consts", since = "1.41.0")]
+            pub const MAX: Self = !Self::MIN;
+        }
+
+        doc_comment! {
+            "Returns the smallest value that can be represented by this integer type.",
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[rustc_deprecated(since = "1.41.0", reason = "replaced by associated constant MIN")]
+            #[inline(always)]
+            #[rustc_promotable]
+            #[rustc_const_stable(feature = "const_min_value", since = "1.32.0")]
+            pub const fn min_value() -> Self {
+                Self::MIN
+            }
+        }
+
+        doc_comment! {
+            "Returns the largest value that can be represented by this integer type.",
             #[stable(feature = "rust1", since = "1.0.0")]
             #[rustc_deprecated(since = "1.41.0", reason = "replaced by associated constant MAX")]
             #[inline(always)]
             #[rustc_promotable]
             #[rustc_const_stable(feature = "const_max_value", since = "1.32.0")]
             pub const fn max_value() -> Self {
-                !Self::min_value()
+                Self::MAX
             }
         }
 
@@ -2341,38 +2353,52 @@ macro_rules! uint_impl {
         $reversed:expr, $le_bytes:expr, $be_bytes:expr,
         $to_xe_bytes_doc:expr, $from_xe_bytes_doc:expr) => {
         doc_comment! {
-            concat!("Returns the smallest value that can be represented by this integer type.
+            concat!("The smallest value that can be represented by this integer type.
 
 # Examples
 
 Basic usage:
 
 ```
-", $Feature, "assert_eq!(", stringify!($SelfT), "::min_value(), 0);", $EndFeature, "
+", $Feature, "assert_eq!(", stringify!($SelfT), "::MIN, 0);", $EndFeature, "
 ```"),
-            #[stable(feature = "rust1", since = "1.0.0")]
-            #[rustc_promotable]
-            #[inline(always)]
-            #[rustc_const_stable(feature = "const_min_value", since = "1.32.0")]
-            pub const fn min_value() -> Self { 0 }
+            #[stable(feature = "assoc_int_consts", since = "1.41.0")]
+            pub const MIN: Self = 0;
         }
 
         doc_comment! {
-            concat!("Returns the largest value that can be represented by this integer type.
+            concat!("The largest value that can be represented by this integer type.
 
 # Examples
 
 Basic usage:
 
 ```
-", $Feature, "assert_eq!(", stringify!($SelfT), "::max_value(), ",
-stringify!($MaxV), ");", $EndFeature, "
+", $Feature, "assert_eq!(", stringify!($SelfT), "::MAX, ", stringify!($MaxV), ");",
+$EndFeature, "
 ```"),
+            #[stable(feature = "assoc_int_consts", since = "1.41.0")]
+            pub const MAX: Self = !0;
+        }
+
+        doc_comment! {
+            "Returns the smallest value that can be represented by this integer type.",
             #[stable(feature = "rust1", since = "1.0.0")]
+            #[rustc_deprecated(since = "1.41.0", reason = "replaced by associated constant MIN")]
+            #[rustc_promotable]
+            #[inline(always)]
+            #[rustc_const_stable(feature = "const_max_value", since = "1.32.0")]
+            pub const fn min_value() -> Self { Self::MIN }
+        }
+
+        doc_comment! {
+            "Returns the largest value that can be represented by this integer type.",
+            #[stable(feature = "rust1", since = "1.0.0")]
+            #[rustc_deprecated(since = "1.41.0", reason = "replaced by associated constant MAX")]
             #[rustc_promotable]
             #[inline(always)]
             #[rustc_const_stable(feature = "const_max_value", since = "1.32.0")]
-            pub const fn max_value() -> Self { !0 }
+            pub const fn max_value() -> Self { Self::MAX }
         }
 
         doc_comment! {

From c127d8f11f65b5472ccc36b8daf34c302648eb92 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= <faern@faern.net>
Date: Tue, 17 Dec 2019 09:23:14 +0100
Subject: [PATCH 05/15] Don't mention interger modules on primitive docs

---
 src/libstd/primitive_docs.rs | 24 ------------------------
 1 file changed, 24 deletions(-)

diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs
index d4b41e11c0e82..b6bd709efe789 100644
--- a/src/libstd/primitive_docs.rs
+++ b/src/libstd/primitive_docs.rs
@@ -788,80 +788,60 @@ mod prim_f64 {}
 #[doc(primitive = "i8")]
 //
 /// The 8-bit signed integer type.
-///
-/// *[See also the `std::i8` module](i8/index.html).*
 #[stable(feature = "rust1", since = "1.0.0")]
 mod prim_i8 {}
 
 #[doc(primitive = "i16")]
 //
 /// The 16-bit signed integer type.
-///
-/// *[See also the `std::i16` module](i16/index.html).*
 #[stable(feature = "rust1", since = "1.0.0")]
 mod prim_i16 {}
 
 #[doc(primitive = "i32")]
 //
 /// The 32-bit signed integer type.
-///
-/// *[See also the `std::i32` module](i32/index.html).*
 #[stable(feature = "rust1", since = "1.0.0")]
 mod prim_i32 {}
 
 #[doc(primitive = "i64")]
 //
 /// The 64-bit signed integer type.
-///
-/// *[See also the `std::i64` module](i64/index.html).*
 #[stable(feature = "rust1", since = "1.0.0")]
 mod prim_i64 {}
 
 #[doc(primitive = "i128")]
 //
 /// The 128-bit signed integer type.
-///
-/// *[See also the `std::i128` module](i128/index.html).*
 #[stable(feature = "i128", since = "1.26.0")]
 mod prim_i128 {}
 
 #[doc(primitive = "u8")]
 //
 /// The 8-bit unsigned integer type.
-///
-/// *[See also the `std::u8` module](u8/index.html).*
 #[stable(feature = "rust1", since = "1.0.0")]
 mod prim_u8 {}
 
 #[doc(primitive = "u16")]
 //
 /// The 16-bit unsigned integer type.
-///
-/// *[See also the `std::u16` module](u16/index.html).*
 #[stable(feature = "rust1", since = "1.0.0")]
 mod prim_u16 {}
 
 #[doc(primitive = "u32")]
 //
 /// The 32-bit unsigned integer type.
-///
-/// *[See also the `std::u32` module](u32/index.html).*
 #[stable(feature = "rust1", since = "1.0.0")]
 mod prim_u32 {}
 
 #[doc(primitive = "u64")]
 //
 /// The 64-bit unsigned integer type.
-///
-/// *[See also the `std::u64` module](u64/index.html).*
 #[stable(feature = "rust1", since = "1.0.0")]
 mod prim_u64 {}
 
 #[doc(primitive = "u128")]
 //
 /// The 128-bit unsigned integer type.
-///
-/// *[See also the `std::u128` module](u128/index.html).*
 #[stable(feature = "i128", since = "1.26.0")]
 mod prim_u128 {}
 
@@ -869,8 +849,6 @@ mod prim_u128 {}
 //
 /// The pointer-sized signed integer type.
 ///
-/// *[See also the `std::isize` module](isize/index.html).*
-///
 /// The size of this primitive is how many bytes it takes to reference any
 /// location in memory. For example, on a 32 bit target, this is 4 bytes
 /// and on a 64 bit target, this is 8 bytes.
@@ -881,8 +859,6 @@ mod prim_isize {}
 //
 /// The pointer-sized unsigned integer type.
 ///
-/// *[See also the `std::usize` module](usize/index.html).*
-///
 /// The size of this primitive is how many bytes it takes to reference any
 /// location in memory. For example, on a 32 bit target, this is 4 bytes
 /// and on a 64 bit target, this is 8 bytes.

From 5f687fbf21fb86d2cc610878829555969c37fe15 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= <faern@faern.net>
Date: Tue, 17 Dec 2019 19:25:21 +0100
Subject: [PATCH 06/15] Replace all usages of min_value/max_value with assoc
 const MIN/MAX

---
 src/liballoc/rc.rs                            |   4 +-
 src/liballoc/rc/tests.rs                      |   4 +-
 src/liballoc/slice.rs                         |   2 +-
 src/liballoc/str.rs                           |   2 +-
 src/liballoc/sync/tests.rs                    |   4 +-
 src/liballoc/tests/str.rs                     |   4 +-
 src/liballoc/tests/vec.rs                     |  18 +--
 src/libcore/cell.rs                           |  10 +-
 src/libcore/convert/num.rs                    |   6 +-
 src/libcore/intrinsics.rs                     |  12 +-
 src/libcore/iter/traits/iterator.rs           |   2 +-
 src/libcore/num/int_macros.rs                 |   4 +-
 src/libcore/num/mod.rs                        | 150 +++++++++---------
 src/libcore/num/uint_macros.rs                |   4 +-
 src/libcore/num/wrapping.rs                   |  20 +--
 src/libcore/ptr/mod.rs                        |   4 +-
 src/libcore/slice/mod.rs                      |  12 +-
 src/libcore/str/mod.rs                        |  18 +--
 src/libcore/tests/num/mod.rs                  |  32 ++--
 src/libcore/tests/ptr.rs                      |   2 +-
 src/libcore/tests/slice.rs                    |   4 +-
 src/librustc/mir/interpret/allocation.rs      |  14 +-
 src/librustc/mir/interpret/pointer.rs         |   4 +-
 src/librustc/ty/layout.rs                     |   4 +-
 src/librustc/ty/print/pretty.rs               |   2 +-
 src/librustc/ty/util.rs                       |   6 +-
 src/librustc_apfloat/lib.rs                   |   6 +-
 src/librustc_data_structures/base_n/tests.rs  |   4 +-
 src/librustc_expand/proc_macro_server.rs      |   8 +-
 src/librustc_lexer/src/unescape.rs            |   2 +-
 src/librustc_lint/types.rs                    |  24 +--
 src/librustc_metadata/creader.rs              |   2 +-
 src/librustc_mir/build/matches/simplify.rs    |   4 +-
 src/librustc_mir/hair/pattern/_match.rs       |   2 +-
 src/librustc_mir/interpret/intrinsics.rs      |   2 +-
 src/librustc_mir/interpret/validity.rs        |   2 +-
 src/librustc_resolve/late.rs                  |   2 +-
 src/librustc_save_analysis/lib.rs             |   2 +-
 src/librustc_span/lib.rs                      |   2 +-
 src/librustc_span/source_map.rs               |   4 +-
 src/libstd/io/buffered.rs                     |  10 +-
 src/libstd/io/cursor.rs                       |   2 +-
 src/libstd/sync/mpsc/mod.rs                   |   3 +-
 src/libstd/sys/cloudabi/condvar.rs            |   2 +-
 src/libstd/sys/hermit/condvar.rs              |   2 +-
 src/libstd/sys/unix/android.rs                |   2 +-
 src/libstd/sys/unix/condvar.rs                |   8 +-
 src/libstd/sys/unix/ext/net.rs                |   2 +-
 src/libstd/sys/unix/fd.rs                     |  10 +-
 src/libstd/sys/unix/fs.rs                     |   2 +-
 src/libstd/sys/unix/net.rs                    |   6 +-
 src/libstd/sys/unix/thread.rs                 |   2 +-
 src/libstd/sys/vxworks/condvar.rs             |   8 +-
 src/libstd/sys/vxworks/fd.rs                  |   6 +-
 src/libstd/sys/vxworks/net.rs                 |   6 +-
 src/libstd/sys/vxworks/thread.rs              |   2 +-
 src/libstd/sys/wasi/mod.rs                    |   2 +-
 src/libstd/sys/wasi/thread.rs                 |   2 +-
 src/libstd/sys/wasm/condvar_atomics.rs        |   4 +-
 src/libstd/sys/wasm/thread.rs                 |   2 +-
 src/libstd/sys/windows/handle.rs              |  10 +-
 src/libstd/sys/windows/io.rs                  |   4 +-
 src/libstd/sys/windows/mod.rs                 |   2 +-
 src/libstd/sys/windows/net.rs                 |   8 +-
 src/libstd/sys_common/net.rs                  |   6 +-
 src/libstd/time.rs                            |   4 +-
 src/test/run-fail/issue-44216-add-instant.rs  |   2 +-
 .../run-fail/issue-44216-add-system-time.rs   |   2 +-
 src/test/run-fail/issue-44216-sub-instant.rs  |   2 +-
 .../run-fail/issue-44216-sub-system-time.rs   |   2 +-
 .../ui/consts/const-eval/shift_overflow.rs    |   2 +-
 .../consts/const-eval/shift_overflow.stderr   |   2 +-
 src/test/ui/consts/const-eval/ub-wide-ptr.rs  |   2 +-
 .../ui/consts/const-int-conversion-rpass.rs   |   4 +-
 src/test/ui/consts/const-int-conversion.rs    |   2 +-
 .../ui/consts/const-int-conversion.stderr     |   2 +-
 .../ui/consts/const-int-overflowing-rpass.rs  |   8 +-
 .../ui/consts/const-int-saturating-arith.rs   |  32 ++--
 .../ui/consts/const-int-wrapping-rpass.rs     |   8 +-
 src/test/ui/consts/promote_fn_calls_std.rs    |  48 +++---
 src/test/ui/issues/issue-8460.rs              |  20 +--
 .../ui/iterators/iter-step-overflow-debug.rs  |   4 +-
 .../ui/iterators/iter-step-overflow-ndebug.rs |   8 +-
 .../ui/iterators/iter-sum-overflow-debug.rs   |   8 +-
 .../ui/iterators/iter-sum-overflow-ndebug.rs  |  16 +-
 .../iter-sum-overflow-overflow-checks.rs      |   8 +-
 src/test/ui/numbers-arithmetic/i128.rs        |   2 +-
 .../ui/numbers-arithmetic/int-abs-overflow.rs |  10 +-
 .../promoted_overflow_opt.rs                  |   2 +-
 src/test/ui/numbers-arithmetic/u128.rs        |   4 +-
 ...intrinsic-generic-arithmetic-saturating.rs |   6 +-
 .../ui/simd/simd-intrinsic-generic-bitmask.rs |   2 +-
 .../simd/simd-intrinsic-generic-reduction.rs  |   2 +-
 93 files changed, 360 insertions(+), 381 deletions(-)

diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs
index 3080a8bf45966..2ea10cc3c306b 100644
--- a/src/liballoc/rc.rs
+++ b/src/liballoc/rc.rs
@@ -1997,7 +1997,7 @@ trait RcBoxPtr<T: ?Sized> {
         // The reference count will never be zero when this is called;
         // nevertheless, we insert an abort here to hint LLVM at
         // an otherwise missed optimization.
-        if strong == 0 || strong == usize::max_value() {
+        if strong == 0 || strong == usize::MAX {
             unsafe {
                 abort();
             }
@@ -2023,7 +2023,7 @@ trait RcBoxPtr<T: ?Sized> {
         // The reference count will never be zero when this is called;
         // nevertheless, we insert an abort here to hint LLVM at
         // an otherwise missed optimization.
-        if weak == 0 || weak == usize::max_value() {
+        if weak == 0 || weak == usize::MAX {
             unsafe {
                 abort();
             }
diff --git a/src/liballoc/rc/tests.rs b/src/liballoc/rc/tests.rs
index 56788bb56d550..e88385faf4fd4 100644
--- a/src/liballoc/rc/tests.rs
+++ b/src/liballoc/rc/tests.rs
@@ -407,14 +407,14 @@ fn test_from_vec() {
 fn test_downcast() {
     use std::any::Any;
 
-    let r1: Rc<dyn Any> = Rc::new(i32::max_value());
+    let r1: Rc<dyn Any> = Rc::new(i32::MAX);
     let r2: Rc<dyn Any> = Rc::new("abc");
 
     assert!(r1.clone().downcast::<u32>().is_err());
 
     let r1i32 = r1.downcast::<i32>();
     assert!(r1i32.is_ok());
-    assert_eq!(r1i32.unwrap(), Rc::new(i32::max_value()));
+    assert_eq!(r1i32.unwrap(), Rc::new(i32::MAX));
 
     assert!(r2.clone().downcast::<i32>().is_err());
 
diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs
index 7b83658fca60d..4e538a01ea86c 100644
--- a/src/liballoc/slice.rs
+++ b/src/liballoc/slice.rs
@@ -433,7 +433,7 @@ impl<T> [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<T>
diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs
index 843a2f1f8e9fc..70860c09a2c31 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/liballoc/sync/tests.rs b/src/liballoc/sync/tests.rs
index edc2820ee22f1..29c7825778e24 100644
--- a/src/liballoc/sync/tests.rs
+++ b/src/liballoc/sync/tests.rs
@@ -463,14 +463,14 @@ fn test_from_vec() {
 fn test_downcast() {
     use std::any::Any;
 
-    let r1: Arc<dyn Any + Send + Sync> = Arc::new(i32::max_value());
+    let r1: Arc<dyn Any + Send + Sync> = Arc::new(i32::MAX);
     let r2: Arc<dyn Any + Send + Sync> = Arc::new("abc");
 
     assert!(r1.clone().downcast::<u32>().is_err());
 
     let r1i32 = r1.downcast::<i32>();
     assert!(r1i32.is_ok());
-    assert_eq!(r1i32.unwrap(), Arc::new(i32::max_value()));
+    assert_eq!(r1i32.unwrap(), Arc::new(i32::MAX));
 
     assert!(r2.clone().downcast::<i32>().is_err());
 
diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs
index d3c72615696d5..68d8b5392cbf1 100644
--- a/src/liballoc/tests/str.rs
+++ b/src/liballoc/tests/str.rs
@@ -566,13 +566,13 @@ mod slice_index {
                 data: "hello";
                 // note: using 0 specifically ensures that the result of overflowing is 0..0,
                 //       so that `get` doesn't simply return None for the wrong reason.
-                bad: data[0..=usize::max_value()];
+                bad: data[0..=usize::MAX];
                 message: "maximum usize";
             }
 
             in mod rangetoinclusive {
                 data: "hello";
-                bad: data[..=usize::max_value()];
+                bad: data[..=usize::MAX];
                 message: "maximum usize";
             }
         }
diff --git a/src/liballoc/tests/vec.rs b/src/liballoc/tests/vec.rs
index 2a9bfefc713e7..ed68e8a8a1525 100644
--- a/src/liballoc/tests/vec.rs
+++ b/src/liballoc/tests/vec.rs
@@ -68,7 +68,7 @@ fn test_reserve() {
 
 #[test]
 fn test_zst_capacity() {
-    assert_eq!(Vec::<()>::new().capacity(), usize::max_value());
+    assert_eq!(Vec::<()>::new().capacity(), usize::MAX);
 }
 
 #[test]
@@ -563,19 +563,19 @@ fn test_drain_inclusive_range() {
 
 #[test]
 fn test_drain_max_vec_size() {
-    let mut v = Vec::<()>::with_capacity(usize::max_value());
+    let mut v = Vec::<()>::with_capacity(usize::MAX);
     unsafe {
-        v.set_len(usize::max_value());
+        v.set_len(usize::MAX);
     }
-    for _ in v.drain(usize::max_value() - 1..) {}
-    assert_eq!(v.len(), usize::max_value() - 1);
+    for _ in v.drain(usize::MAX - 1..) {}
+    assert_eq!(v.len(), usize::MAX - 1);
 
-    let mut v = Vec::<()>::with_capacity(usize::max_value());
+    let mut v = Vec::<()>::with_capacity(usize::MAX);
     unsafe {
-        v.set_len(usize::max_value());
+        v.set_len(usize::MAX);
     }
-    for _ in v.drain(usize::max_value() - 1..=usize::max_value() - 1) {}
-    assert_eq!(v.len(), usize::max_value() - 1);
+    for _ in v.drain(usize::MAX - 1..=usize::MAX - 1) {}
+    assert_eq!(v.len(), usize::MAX - 1);
 }
 
 #[test]
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs
index 4fcd0d9737d56..0fa9ae2974dfa 100644
--- a/src/libcore/cell.rs
+++ b/src/libcore/cell.rs
@@ -1097,8 +1097,8 @@ impl<'b> BorrowRef<'b> {
             // Incrementing borrow can result in a non-reading value (<= 0) in these cases:
             // 1. It was < 0, i.e. there are writing borrows, so we can't allow a read borrow
             //    due to Rust's reference aliasing rules
-            // 2. It was isize::max_value() (the max amount of reading borrows) and it overflowed
-            //    into isize::min_value() (the max amount of writing borrows) so we can't allow
+            // 2. It was isize::MAX (the max amount of reading borrows) and it overflowed
+            //    into isize::MIN (the max amount of writing borrows) so we can't allow
             //    an additional read borrow because isize can't represent so many read borrows
             //    (this can only happen if you mem::forget more than a small constant amount of
             //    `Ref`s, which is not good practice)
@@ -1106,7 +1106,7 @@ impl<'b> BorrowRef<'b> {
         } else {
             // Incrementing borrow can result in a reading value (> 0) in these cases:
             // 1. It was = 0, i.e. it wasn't borrowed, and we are taking the first read borrow
-            // 2. It was > 0 and < isize::max_value(), i.e. there were read borrows, and isize
+            // 2. It was > 0 and < isize::MAX, i.e. there were read borrows, and isize
             //    is large enough to represent having one more read borrow
             borrow.set(b);
             Some(BorrowRef { borrow })
@@ -1132,7 +1132,7 @@ impl Clone for BorrowRef<'_> {
         debug_assert!(is_reading(borrow));
         // Prevent the borrow counter from overflowing into
         // a writing borrow.
-        assert!(borrow != isize::max_value());
+        assert!(borrow != isize::MAX);
         self.borrow.set(borrow + 1);
         BorrowRef { borrow: self.borrow }
     }
@@ -1356,7 +1356,7 @@ impl<'b> BorrowRefMut<'b> {
         let borrow = self.borrow.get();
         debug_assert!(is_writing(borrow));
         // Prevent the borrow counter from underflowing.
-        assert!(borrow != isize::min_value());
+        assert!(borrow != isize::MIN);
         self.borrow.set(borrow - 1);
         BorrowRefMut { borrow: self.borrow }
     }
diff --git a/src/libcore/convert/num.rs b/src/libcore/convert/num.rs
index 752199c94b8ae..8440e3924e078 100644
--- a/src/libcore/convert/num.rs
+++ b/src/libcore/convert/num.rs
@@ -217,7 +217,7 @@ macro_rules! try_from_upper_bounded {
             /// is outside of the range of the target type.
             #[inline]
             fn try_from(u: $source) -> Result<Self, Self::Error> {
-                if u > (Self::max_value() as $source) {
+                if u > (Self::MAX as $source) {
                     Err(TryFromIntError(()))
                 } else {
                     Ok(u as Self)
@@ -239,8 +239,8 @@ macro_rules! try_from_both_bounded {
             /// is outside of the range of the target type.
             #[inline]
             fn try_from(u: $source) -> Result<Self, Self::Error> {
-                let min = Self::min_value() as $source;
-                let max = Self::max_value() as $source;
+                let min = Self::MIN as $source;
+                let max = Self::MAX as $source;
                 if u < min || u > max {
                     Err(TryFromIntError(()))
                 } else {
diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs
index 416c73f50bd89..0921cec77947b 100644
--- a/src/libcore/intrinsics.rs
+++ b/src/libcore/intrinsics.rs
@@ -1300,14 +1300,14 @@ extern "rust-intrinsic" {
     pub fn mul_with_overflow<T>(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<T>(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
     pub fn unchecked_div<T>(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
     pub fn unchecked_rem<T>(x: T, y: T) -> T;
 
     /// Performs an unchecked left shift, resulting in undefined behavior when
@@ -1320,15 +1320,15 @@ extern "rust-intrinsic" {
     pub fn unchecked_shr<T>(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`.
     pub fn unchecked_add<T>(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`.
     pub fn unchecked_sub<T>(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`.
     pub fn unchecked_mul<T>(x: T, y: T) -> T;
 
     /// Performs rotate left.
diff --git a/src/libcore/iter/traits/iterator.rs b/src/libcore/iter/traits/iterator.rs
index c958289b2c935..6e6613ee5e9d9 100644
--- a/src/libcore/iter/traits/iterator.rs
+++ b/src/libcore/iter/traits/iterator.rs
@@ -195,7 +195,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/num/int_macros.rs b/src/libcore/num/int_macros.rs
index a2aa80982cbe9..f2f91e92adff4 100644
--- a/src/libcore/num/int_macros.rs
+++ b/src/libcore/num/int_macros.rs
@@ -6,10 +6,10 @@ macro_rules! int_module {
         /// The smallest value that can be represented by this integer type.
         #[$attr]
         #[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant MIN")]
-        pub const MIN: $T = $T::min_value();
+        pub const MIN: $T = $T::MIN;
         /// The largest value that can be represented by this integer type.
         #[$attr]
         #[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant MAX")]
-        pub const MAX: $T = $T::max_value();
+        pub const MAX: $T = $T::MAX;
     )
 }
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 9a26385fb255d..3294ecfc25a66 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -355,7 +355,7 @@ $EndFeature, "
 Basic usage:
 
 ```
-", $Feature, "assert_eq!(", stringify!($SelfT), "::max_value().count_zeros(), 1);", $EndFeature, "
+", $Feature, "assert_eq!(", stringify!($SelfT), "::MAX.count_zeros(), 1);", $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
             #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
@@ -650,8 +650,8 @@ Basic usage:
 
 ```
 ", $Feature, "assert_eq!((", stringify!($SelfT),
-"::max_value() - 2).checked_add(1), Some(", stringify!($SelfT), "::max_value() - 1));
-assert_eq!((", stringify!($SelfT), "::max_value() - 2).checked_add(3), None);",
+"::MAX - 2).checked_add(1), Some(", stringify!($SelfT), "::MAX - 1));
+assert_eq!((", stringify!($SelfT), "::MAX - 2).checked_add(3), None);",
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
@@ -674,8 +674,8 @@ Basic usage:
 
 ```
 ", $Feature, "assert_eq!((", stringify!($SelfT),
-"::min_value() + 2).checked_sub(1), Some(", stringify!($SelfT), "::min_value() + 1));
-assert_eq!((", stringify!($SelfT), "::min_value() + 2).checked_sub(3), None);",
+"::MIN + 2).checked_sub(1), Some(", stringify!($SelfT), "::MIN + 1));
+assert_eq!((", stringify!($SelfT), "::MIN + 2).checked_sub(3), None);",
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
@@ -698,8 +698,8 @@ Basic usage:
 
 ```
 ", $Feature, "assert_eq!(", stringify!($SelfT),
-"::max_value().checked_mul(1), Some(", stringify!($SelfT), "::max_value()));
-assert_eq!(", stringify!($SelfT), "::max_value().checked_mul(2), None);",
+"::MAX.checked_mul(1), Some(", stringify!($SelfT), "::MAX));
+assert_eq!(", stringify!($SelfT), "::MAX.checked_mul(2), None);",
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
@@ -722,8 +722,8 @@ Basic usage:
 
 ```
 ", $Feature, "assert_eq!((", stringify!($SelfT),
-"::min_value() + 1).checked_div(-1), Some(", stringify!($Max), "));
-assert_eq!(", stringify!($SelfT), "::min_value().checked_div(-1), None);
+"::MIN + 1).checked_div(-1), Some(", stringify!($Max), "));
+assert_eq!(", stringify!($SelfT), "::MIN.checked_div(-1), None);
 assert_eq!((1", stringify!($SelfT), ").checked_div(0), None);",
 $EndFeature, "
 ```"),
@@ -732,7 +732,7 @@ $EndFeature, "
                           without modifying the original"]
             #[inline]
             pub fn checked_div(self, rhs: Self) -> Option<Self> {
-                if rhs == 0 || (self == Self::min_value() && rhs == -1) {
+                if rhs == 0 || (self == Self::MIN && rhs == -1) {
                     None
                 } else {
                     // SAFETY: div by zero and by INT_MIN have been checked above
@@ -751,8 +751,8 @@ Basic usage:
 
 ```
 assert_eq!((", stringify!($SelfT),
-"::min_value() + 1).checked_div_euclid(-1), Some(", stringify!($Max), "));
-assert_eq!(", stringify!($SelfT), "::min_value().checked_div_euclid(-1), None);
+"::MIN + 1).checked_div_euclid(-1), Some(", stringify!($Max), "));
+assert_eq!(", stringify!($SelfT), "::MIN.checked_div_euclid(-1), None);
 assert_eq!((1", stringify!($SelfT), ").checked_div_euclid(0), None);
 ```"),
             #[stable(feature = "euclidean_division", since = "1.38.0")]
@@ -760,7 +760,7 @@ assert_eq!((1", stringify!($SelfT), ").checked_div_euclid(0), None);
                           without modifying the original"]
             #[inline]
             pub fn checked_div_euclid(self, rhs: Self) -> Option<Self> {
-                if rhs == 0 || (self == Self::min_value() && rhs == -1) {
+                if rhs == 0 || (self == Self::MIN && rhs == -1) {
                     None
                 } else {
                     Some(self.div_euclid(rhs))
@@ -789,7 +789,7 @@ $EndFeature, "
                           without modifying the original"]
             #[inline]
             pub fn checked_rem(self, rhs: Self) -> Option<Self> {
-                if rhs == 0 || (self == Self::min_value() && rhs == -1) {
+                if rhs == 0 || (self == Self::MIN && rhs == -1) {
                     None
                 } else {
                     // SAFETY: div by zero and by INT_MIN have been checked above
@@ -818,7 +818,7 @@ assert_eq!(", stringify!($SelfT), "::MIN.checked_rem_euclid(-1), None);
                           without modifying the original"]
             #[inline]
             pub fn checked_rem_euclid(self, rhs: Self) -> Option<Self> {
-                if rhs == 0 || (self == Self::min_value() && rhs == -1) {
+                if rhs == 0 || (self == Self::MIN && rhs == -1) {
                     None
                 } else {
                     Some(self.rem_euclid(rhs))
@@ -930,7 +930,7 @@ Basic usage:
 
 ```
 ", $Feature, "assert_eq!(8", stringify!($SelfT), ".checked_pow(2), Some(64));
-assert_eq!(", stringify!($SelfT), "::max_value().checked_pow(2), None);",
+assert_eq!(", stringify!($SelfT), "::MAX.checked_pow(2), None);",
 $EndFeature, "
 ```"),
 
@@ -971,10 +971,10 @@ Basic usage:
 
 ```
 ", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101);
-assert_eq!(", stringify!($SelfT), "::max_value().saturating_add(100), ", stringify!($SelfT),
-"::max_value());
-assert_eq!(", stringify!($SelfT), "::min_value().saturating_add(-1), ", stringify!($SelfT),
-"::min_value());",
+assert_eq!(", stringify!($SelfT), "::MAX.saturating_add(100), ", stringify!($SelfT),
+"::MAX);
+assert_eq!(", stringify!($SelfT), "::MIN.saturating_add(-1), ", stringify!($SelfT),
+"::MIN);",
 $EndFeature, "
 ```"),
 
@@ -998,10 +998,10 @@ Basic usage:
 
 ```
 ", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_sub(127), -27);
-assert_eq!(", stringify!($SelfT), "::min_value().saturating_sub(100), ", stringify!($SelfT),
-"::min_value());
-assert_eq!(", stringify!($SelfT), "::max_value().saturating_sub(-1), ", stringify!($SelfT),
-"::max_value());",
+assert_eq!(", stringify!($SelfT), "::MIN.saturating_sub(100), ", stringify!($SelfT),
+"::MIN);
+assert_eq!(", stringify!($SelfT), "::MAX.saturating_sub(-1), ", stringify!($SelfT),
+"::MAX);",
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
@@ -1026,10 +1026,10 @@ Basic usage:
 ", $Feature, "#![feature(saturating_neg)]
 assert_eq!(100", stringify!($SelfT), ".saturating_neg(), -100);
 assert_eq!((-100", stringify!($SelfT), ").saturating_neg(), 100);
-assert_eq!(", stringify!($SelfT), "::min_value().saturating_neg(), ", stringify!($SelfT),
-"::max_value());
-assert_eq!(", stringify!($SelfT), "::max_value().saturating_neg(), ", stringify!($SelfT),
-"::min_value() + 1);",
+assert_eq!(", stringify!($SelfT), "::MIN.saturating_neg(), ", stringify!($SelfT),
+"::MAX);
+assert_eq!(", stringify!($SelfT), "::MAX.saturating_neg(), ", stringify!($SelfT),
+"::MIN + 1);",
 $EndFeature, "
 ```"),
 
@@ -1052,10 +1052,10 @@ Basic usage:
 ", $Feature, "#![feature(saturating_neg)]
 assert_eq!(100", stringify!($SelfT), ".saturating_abs(), 100);
 assert_eq!((-100", stringify!($SelfT), ").saturating_abs(), 100);
-assert_eq!(", stringify!($SelfT), "::min_value().saturating_abs(), ", stringify!($SelfT),
-"::max_value());
-assert_eq!((", stringify!($SelfT), "::min_value() + 1).saturating_abs(), ", stringify!($SelfT),
-"::max_value());",
+assert_eq!(", stringify!($SelfT), "::MIN.saturating_abs(), ", stringify!($SelfT),
+"::MAX);
+assert_eq!((", stringify!($SelfT), "::MIN + 1).saturating_abs(), ", stringify!($SelfT),
+"::MAX);",
 $EndFeature, "
 ```"),
 
@@ -1093,9 +1093,9 @@ $EndFeature, "
             pub fn saturating_mul(self, rhs: Self) -> Self {
                 self.checked_mul(rhs).unwrap_or_else(|| {
                     if (self < 0) == (rhs < 0) {
-                        Self::max_value()
+                        Self::MAX
                     } else {
-                        Self::min_value()
+                        Self::MIN
                     }
                 })
             }
@@ -1124,8 +1124,8 @@ $EndFeature, "
             pub fn saturating_pow(self, exp: u32) -> Self {
                 match self.checked_pow(exp) {
                     Some(x) => x,
-                    None if self < 0 && exp % 2 == 1 => Self::min_value(),
-                    None => Self::max_value(),
+                    None if self < 0 && exp % 2 == 1 => Self::MIN,
+                    None => Self::MAX,
                 }
             }
         }
@@ -1140,8 +1140,8 @@ Basic usage:
 
 ```
 ", $Feature, "assert_eq!(100", stringify!($SelfT), ".wrapping_add(27), 127);
-assert_eq!(", stringify!($SelfT), "::max_value().wrapping_add(2), ", stringify!($SelfT),
-"::min_value() + 1);",
+assert_eq!(", stringify!($SelfT), "::MAX.wrapping_add(2), ", stringify!($SelfT),
+"::MIN + 1);",
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
@@ -1164,8 +1164,8 @@ Basic usage:
 
 ```
 ", $Feature, "assert_eq!(0", stringify!($SelfT), ".wrapping_sub(127), -127);
-assert_eq!((-2", stringify!($SelfT), ").wrapping_sub(", stringify!($SelfT), "::max_value()), ",
-stringify!($SelfT), "::max_value());",
+assert_eq!((-2", stringify!($SelfT), ").wrapping_sub(", stringify!($SelfT), "::MAX), ",
+stringify!($SelfT), "::MAX);",
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
@@ -1332,8 +1332,8 @@ Basic usage:
 
 ```
 ", $Feature, "assert_eq!(100", stringify!($SelfT), ".wrapping_neg(), -100);
-assert_eq!(", stringify!($SelfT), "::min_value().wrapping_neg(), ", stringify!($SelfT),
-"::min_value());",
+assert_eq!(", stringify!($SelfT), "::MIN.wrapping_neg(), ", stringify!($SelfT),
+"::MIN);",
 $EndFeature, "
 ```"),
             #[stable(feature = "num_wrapping", since = "1.2.0")]
@@ -1423,8 +1423,8 @@ Basic usage:
 ```
 ", $Feature, "assert_eq!(100", stringify!($SelfT), ".wrapping_abs(), 100);
 assert_eq!((-100", stringify!($SelfT), ").wrapping_abs(), 100);
-assert_eq!(", stringify!($SelfT), "::min_value().wrapping_abs(), ", stringify!($SelfT),
-"::min_value());
+assert_eq!(", stringify!($SelfT), "::MIN.wrapping_abs(), ", stringify!($SelfT),
+"::MIN);
 assert_eq!((-128i8).wrapping_abs() as u8, 128);",
 $EndFeature, "
 ```"),
@@ -1591,7 +1591,7 @@ $EndFeature, "
             #[must_use = "this returns the result of the operation, \
                           without modifying the original"]
             pub fn overflowing_div(self, rhs: Self) -> (Self, bool) {
-                if self == Self::min_value() && rhs == -1 {
+                if self == Self::MIN && rhs == -1 {
                     (self, true)
                 } else {
                     (self / rhs, false)
@@ -1625,7 +1625,7 @@ assert_eq!(", stringify!($SelfT), "::MIN.overflowing_div_euclid(-1), (", stringi
             #[must_use = "this returns the result of the operation, \
                           without modifying the original"]
             pub fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool) {
-                if self == Self::min_value() && rhs == -1 {
+                if self == Self::MIN && rhs == -1 {
                     (self, true)
                 } else {
                     (self.div_euclid(rhs), false)
@@ -1659,7 +1659,7 @@ $EndFeature, "
             #[must_use = "this returns the result of the operation, \
                           without modifying the original"]
             pub fn overflowing_rem(self, rhs: Self) -> (Self, bool) {
-                if self == Self::min_value() && rhs == -1 {
+                if self == Self::MIN && rhs == -1 {
                     (0, true)
                 } else {
                     (self % rhs, false)
@@ -1693,7 +1693,7 @@ assert_eq!(", stringify!($SelfT), "::MIN.overflowing_rem_euclid(-1), (0, true));
                           without modifying the original"]
             #[inline]
             pub fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool) {
-                if self == Self::min_value() && rhs == -1 {
+                if self == Self::MIN && rhs == -1 {
                     (0, true)
                 } else {
                     (self.rem_euclid(rhs), false)
@@ -1725,8 +1725,8 @@ assert_eq!(", stringify!($SelfT), "::MIN.overflowing_neg(), (", stringify!($Self
             #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
             #[allow_internal_unstable(const_if_match)]
             pub const fn overflowing_neg(self) -> (Self, bool) {
-                if self == Self::min_value() {
-                    (Self::min_value(), true)
+                if self == Self::MIN {
+                    (Self::MIN, true)
                 } else {
                     (-self, false)
                 }
@@ -1800,15 +1800,15 @@ Basic usage:
 ```
 ", $Feature, "assert_eq!(10", stringify!($SelfT), ".overflowing_abs(), (10, false));
 assert_eq!((-10", stringify!($SelfT), ").overflowing_abs(), (10, false));
-assert_eq!((", stringify!($SelfT), "::min_value()).overflowing_abs(), (", stringify!($SelfT),
-"::min_value(), true));",
+assert_eq!((", stringify!($SelfT), "::MIN).overflowing_abs(), (", stringify!($SelfT),
+"::MIN, true));",
 $EndFeature, "
 ```"),
             #[stable(feature = "no_panic_abs", since = "1.13.0")]
             #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
             #[inline]
             pub const fn overflowing_abs(self) -> (Self, bool) {
-                (self.wrapping_abs(), self == Self::min_value())
+                (self.wrapping_abs(), self == Self::MIN)
             }
         }
 
@@ -1995,10 +1995,10 @@ assert_eq!((-a).rem_euclid(-b), 1);
 
 # Overflow behavior
 
-The absolute value of `", stringify!($SelfT), "::min_value()` cannot be represented as an
+The absolute value of `", stringify!($SelfT), "::MIN` cannot be represented as an
 `", stringify!($SelfT), "`, and attempting to calculate it will cause an overflow. This means that
 code in debug mode will trigger a panic on this case and optimized code will return `",
-stringify!($SelfT), "::min_value()` without a panic.
+stringify!($SelfT), "::MIN` without a panic.
 
 # Examples
 
@@ -2459,7 +2459,7 @@ assert_eq!(n.count_ones(), 3);", $EndFeature, "
 Basic usage:
 
 ```
-", $Feature, "assert_eq!(", stringify!($SelfT), "::max_value().count_zeros(), 0);", $EndFeature, "
+", $Feature, "assert_eq!(", stringify!($SelfT), "::MAX.count_zeros(), 0);", $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
             #[rustc_const_stable(feature = "const_math", since = "1.32.0")]
@@ -2477,7 +2477,7 @@ Basic usage:
 Basic usage:
 
 ```
-", $Feature, "let n = ", stringify!($SelfT), "::max_value() >> 2;
+", $Feature, "let n = ", stringify!($SelfT), "::MAX >> 2;
 
 assert_eq!(n.leading_zeros(), 2);", $EndFeature, "
 ```"),
@@ -2752,9 +2752,9 @@ if overflow occurred.
 Basic usage:
 
 ```
-", $Feature, "assert_eq!((", stringify!($SelfT), "::max_value() - 2).checked_add(1), ",
-"Some(", stringify!($SelfT), "::max_value() - 1));
-assert_eq!((", stringify!($SelfT), "::max_value() - 2).checked_add(3), None);", $EndFeature, "
+", $Feature, "assert_eq!((", stringify!($SelfT), "::MAX - 2).checked_add(1), ",
+"Some(", stringify!($SelfT), "::MAX - 1));
+assert_eq!((", stringify!($SelfT), "::MAX - 2).checked_add(3), None);", $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
             #[must_use = "this returns the result of the operation, \
@@ -2798,7 +2798,7 @@ Basic usage:
 
 ```
 ", $Feature, "assert_eq!(5", stringify!($SelfT), ".checked_mul(1), Some(5));
-assert_eq!(", stringify!($SelfT), "::max_value().checked_mul(2), None);", $EndFeature, "
+assert_eq!(", stringify!($SelfT), "::MAX.checked_mul(2), None);", $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
             #[must_use = "this returns the result of the operation, \
@@ -2990,7 +2990,7 @@ Basic usage:
 
 ```
 ", $Feature, "assert_eq!(2", stringify!($SelfT), ".checked_pow(5), Some(32));
-assert_eq!(", stringify!($SelfT), "::max_value().checked_pow(2), None);", $EndFeature, "
+assert_eq!(", stringify!($SelfT), "::MAX.checked_pow(2), None);", $EndFeature, "
 ```"),
             #[stable(feature = "no_panic_pow", since = "1.34.0")]
             #[must_use = "this returns the result of the operation, \
@@ -3084,7 +3084,7 @@ assert_eq!((", stringify!($SelfT), "::MAX).saturating_mul(10), ", stringify!($Se
                           without modifying the original"]
             #[inline]
             pub fn saturating_mul(self, rhs: Self) -> Self {
-                self.checked_mul(rhs).unwrap_or(Self::max_value())
+                self.checked_mul(rhs).unwrap_or(Self::MAX)
             }
         }
 
@@ -3110,7 +3110,7 @@ $EndFeature, "
             pub fn saturating_pow(self, exp: u32) -> Self {
                 match self.checked_pow(exp) {
                     Some(x) => x,
-                    None => Self::max_value(),
+                    None => Self::MAX,
                 }
             }
         }
@@ -3125,7 +3125,7 @@ Basic usage:
 
 ```
 ", $Feature, "assert_eq!(200", stringify!($SelfT), ".wrapping_add(55), 255);
-assert_eq!(200", stringify!($SelfT), ".wrapping_add(", stringify!($SelfT), "::max_value()), 199);",
+assert_eq!(200", stringify!($SelfT), ".wrapping_add(", stringify!($SelfT), "::MAX), 199);",
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
@@ -3148,7 +3148,7 @@ Basic usage:
 
 ```
 ", $Feature, "assert_eq!(100", stringify!($SelfT), ".wrapping_sub(100), 0);
-assert_eq!(100", stringify!($SelfT), ".wrapping_sub(", stringify!($SelfT), "::max_value()), 101);",
+assert_eq!(100", stringify!($SelfT), ".wrapping_sub(", stringify!($SelfT), "::MAX), 101);",
 $EndFeature, "
 ```"),
             #[stable(feature = "rust1", since = "1.0.0")]
@@ -3883,7 +3883,7 @@ assert!(!10", stringify!($SelfT), ".is_power_of_two());", $EndFeature, "
             // (such as intel pre-haswell) have more efficient ctlz
             // intrinsics when the argument is non-zero.
             let z = unsafe { intrinsics::ctlz_nonzero(p) };
-            <$SelfT>::max_value() >> z
+            <$SelfT>::MAX >> z
         }
 
         doc_comment! {
@@ -3922,7 +3922,7 @@ Basic usage:
 ", $Feature, "assert_eq!(2", stringify!($SelfT),
 ".checked_next_power_of_two(), Some(2));
 assert_eq!(3", stringify!($SelfT), ".checked_next_power_of_two(), Some(4));
-assert_eq!(", stringify!($SelfT), "::max_value().checked_next_power_of_two(), None);",
+assert_eq!(", stringify!($SelfT), "::MAX.checked_next_power_of_two(), None);",
 $EndFeature, "
 ```"),
             #[inline]
@@ -3946,7 +3946,7 @@ Basic usage:
 ", $Feature, "
 assert_eq!(2", stringify!($SelfT), ".wrapping_next_power_of_two(), 2);
 assert_eq!(3", stringify!($SelfT), ".wrapping_next_power_of_two(), 4);
-assert_eq!(", stringify!($SelfT), "::max_value().wrapping_next_power_of_two(), 0);",
+assert_eq!(", stringify!($SelfT), "::MAX.wrapping_next_power_of_two(), 0);",
 $EndFeature, "
 ```"),
             #[unstable(feature = "wrapping_next_power_of_two", issue = "32463",
@@ -4827,8 +4827,8 @@ impl From<!> for TryFromIntError {
 
 #[doc(hidden)]
 trait FromStrRadixHelper: PartialOrd + Copy {
-    fn min_value() -> Self;
-    fn max_value() -> Self;
+    const MIN: Self;
+    const MAX: Self;
     fn from_u32(u: u32) -> Self;
     fn checked_mul(&self, other: u32) -> Option<Self>;
     fn checked_sub(&self, other: u32) -> Option<Self>;
@@ -4837,10 +4837,8 @@ trait FromStrRadixHelper: PartialOrd + Copy {
 
 macro_rules! doit {
     ($($t:ty)*) => ($(impl FromStrRadixHelper for $t {
-        #[inline]
-        fn min_value() -> Self { Self::min_value() }
-        #[inline]
-        fn max_value() -> Self { Self::max_value() }
+        const MIN: Self = Self::MIN;
+        const MAX: Self = Self::MAX;
         #[inline]
         fn from_u32(u: u32) -> Self { u as Self }
         #[inline]
@@ -4873,7 +4871,7 @@ fn from_str_radix<T: FromStrRadixHelper>(src: &str, radix: u32) -> Result<T, Par
         return Err(PIE { kind: Empty });
     }
 
-    let is_signed_ty = T::from_u32(0) > T::min_value();
+    let is_signed_ty = T::from_u32(0) > T::MIN;
 
     // all valid digits are ascii, so we will just iterate over the utf8 bytes
     // and cast them to chars. .to_digit() will safely return None for anything
diff --git a/src/libcore/num/uint_macros.rs b/src/libcore/num/uint_macros.rs
index da1300d2a92d7..d381f10a11b30 100644
--- a/src/libcore/num/uint_macros.rs
+++ b/src/libcore/num/uint_macros.rs
@@ -6,10 +6,10 @@ macro_rules! uint_module {
         /// The smallest value that can be represented by this integer type.
         #[$attr]
         #[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant MIN")]
-        pub const MIN: $T = $T::min_value();
+        pub const MIN: $T = $T::MIN;
         /// The largest value that can be represented by this integer type.
         #[$attr]
         #[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant MAX")]
-        pub const MAX: $T = $T::max_value();
+        pub const MAX: $T = $T::MAX;
     )
 }
diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs
index 82fa6acfbd62a..755773ca2615d 100644
--- a/src/libcore/num/wrapping.rs
+++ b/src/libcore/num/wrapping.rs
@@ -337,13 +337,13 @@ Basic usage:
 #![feature(wrapping_int_impl)]
 use std::num::Wrapping;
 
-assert_eq!(<Wrapping<", stringify!($t), ">>::min_value(), ",
-"Wrapping(", stringify!($t), "::min_value()));
+assert_eq!(<Wrapping<", stringify!($t), ">>::MIN, ",
+"Wrapping(", stringify!($t), "::MIN));
 ```"),
                 #[unstable(feature = "wrapping_int_impl", issue = "32463")]
                 #[inline]
                 pub const fn min_value() -> Self {
-                    Wrapping(<$t>::min_value())
+                    Wrapping(<$t>::MIN)
                 }
             }
 
@@ -358,13 +358,13 @@ Basic usage:
 #![feature(wrapping_int_impl)]
 use std::num::Wrapping;
 
-assert_eq!(<Wrapping<", stringify!($t), ">>::max_value(), ",
-"Wrapping(", stringify!($t), "::max_value()));
+assert_eq!(<Wrapping<", stringify!($t), ">>::MAX, ",
+"Wrapping(", stringify!($t), "::MAX));
 ```"),
                 #[unstable(feature = "wrapping_int_impl", issue = "32463")]
                 #[inline]
                 pub const fn max_value() -> Self {
-                    Wrapping(<$t>::max_value())
+                    Wrapping(<$t>::MAX)
                 }
             }
 
@@ -702,7 +702,7 @@ Basic usage:
 #![feature(wrapping_int_impl)]
 use std::num::Wrapping;
 
-let n = Wrapping(", stringify!($t), "::max_value()) >> 2;
+let n = Wrapping(", stringify!($t), "::MAX) >> 2;
 
 assert_eq!(n.leading_zeros(), 3);
 ```"),
@@ -731,8 +731,8 @@ use std::num::Wrapping;
 
 assert_eq!(Wrapping(100", stringify!($t), ").abs(), Wrapping(100));
 assert_eq!(Wrapping(-100", stringify!($t), ").abs(), Wrapping(100));
-assert_eq!(Wrapping(", stringify!($t), "::min_value()).abs(), Wrapping(", stringify!($t),
-"::min_value()));
+assert_eq!(Wrapping(", stringify!($t), "::MIN).abs(), Wrapping(", stringify!($t),
+"::MIN));
 assert_eq!(Wrapping(-128i8).abs().0 as u8, 128u8);
 ```"),
                 #[inline]
@@ -831,7 +831,7 @@ Basic usage:
 #![feature(wrapping_int_impl)]
 use std::num::Wrapping;
 
-let n = Wrapping(", stringify!($t), "::max_value()) >> 2;
+let n = Wrapping(", stringify!($t), "::MAX) >> 2;
 
 assert_eq!(n.leading_zeros(), 2);
 ```"),
diff --git a/src/libcore/ptr/mod.rs b/src/libcore/ptr/mod.rs
index d7b351f13458a..c0133a3a13867 100644
--- a/src/libcore/ptr/mod.rs
+++ b/src/libcore/ptr/mod.rs
@@ -1090,7 +1090,7 @@ pub(crate) unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usize {
                 //
                 // Note, that we use wrapping operations here intentionally – the original formula
                 // uses e.g., subtraction `mod n`. It is entirely fine to do them `mod
-                // usize::max_value()` instead, because we take the result `mod n` at the end
+                // usize::MAX` instead, because we take the result `mod n` at the end
                 // anyway.
                 inverse = inverse.wrapping_mul(2usize.wrapping_sub(x.wrapping_mul(inverse)))
                     & (going_mod - 1);
@@ -1149,7 +1149,7 @@ pub(crate) unsafe fn align_offset<T: Sized>(p: *const T, a: usize) -> usize {
     }
 
     // Cannot be aligned at all.
-    usize::max_value()
+    usize::MAX
 }
 
 /// Compares raw pointers for equality.
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs
index 9b4d201573238..d3c643bed0a45 100644
--- a/src/libcore/slice/mod.rs
+++ b/src/libcore/slice/mod.rs
@@ -2962,16 +2962,12 @@ impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
 
     #[inline]
     fn get(self, slice: &[T]) -> Option<&[T]> {
-        if *self.end() == usize::max_value() {
-            None
-        } else {
-            (*self.start()..self.end() + 1).get(slice)
-        }
+        if *self.end() == usize::MAX { None } else { (*self.start()..self.end() + 1).get(slice) }
     }
 
     #[inline]
     fn get_mut(self, slice: &mut [T]) -> Option<&mut [T]> {
-        if *self.end() == usize::max_value() {
+        if *self.end() == usize::MAX {
             None
         } else {
             (*self.start()..self.end() + 1).get_mut(slice)
@@ -2990,7 +2986,7 @@ impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
 
     #[inline]
     fn index(self, slice: &[T]) -> &[T] {
-        if *self.end() == usize::max_value() {
+        if *self.end() == usize::MAX {
             slice_index_overflow_fail();
         }
         (*self.start()..self.end() + 1).index(slice)
@@ -2998,7 +2994,7 @@ impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
 
     #[inline]
     fn index_mut(self, slice: &mut [T]) -> &mut [T] {
-        if *self.end() == usize::max_value() {
+        if *self.end() == usize::MAX {
             slice_index_overflow_fail();
         }
         (*self.start()..self.end() + 1).index_mut(slice)
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs
index ab771b1164bad..88724924bfc9c 100644
--- a/src/libcore/str/mod.rs
+++ b/src/libcore/str/mod.rs
@@ -1576,7 +1576,7 @@ fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
             // Ascii case, try to skip forward quickly.
             // When the pointer is aligned, read 2 words of data per iteration
             // until we find a word containing a non-ascii byte.
-            if align != usize::max_value() && align.wrapping_sub(index) % usize_bytes == 0 {
+            if align != usize::MAX && align.wrapping_sub(index) % usize_bytes == 0 {
                 let ptr = v.as_ptr();
                 while index < blocks_end {
                     unsafe {
@@ -1996,7 +1996,7 @@ mod traits {
         type Output = str;
         #[inline]
         fn get(self, slice: &str) -> Option<&Self::Output> {
-            if *self.end() == usize::max_value() {
+            if *self.end() == usize::MAX {
                 None
             } else {
                 (*self.start()..self.end() + 1).get(slice)
@@ -2004,7 +2004,7 @@ mod traits {
         }
         #[inline]
         fn get_mut(self, slice: &mut str) -> Option<&mut Self::Output> {
-            if *self.end() == usize::max_value() {
+            if *self.end() == usize::MAX {
                 None
             } else {
                 (*self.start()..self.end() + 1).get_mut(slice)
@@ -2020,14 +2020,14 @@ mod traits {
         }
         #[inline]
         fn index(self, slice: &str) -> &Self::Output {
-            if *self.end() == usize::max_value() {
+            if *self.end() == usize::MAX {
                 str_index_overflow_fail();
             }
             (*self.start()..self.end() + 1).index(slice)
         }
         #[inline]
         fn index_mut(self, slice: &mut str) -> &mut Self::Output {
-            if *self.end() == usize::max_value() {
+            if *self.end() == usize::MAX {
                 str_index_overflow_fail();
             }
             (*self.start()..self.end() + 1).index_mut(slice)
@@ -2053,11 +2053,11 @@ mod traits {
         type Output = str;
         #[inline]
         fn get(self, slice: &str) -> Option<&Self::Output> {
-            if self.end == usize::max_value() { None } else { (..self.end + 1).get(slice) }
+            if self.end == usize::MAX { None } else { (..self.end + 1).get(slice) }
         }
         #[inline]
         fn get_mut(self, slice: &mut str) -> Option<&mut Self::Output> {
-            if self.end == usize::max_value() { None } else { (..self.end + 1).get_mut(slice) }
+            if self.end == usize::MAX { None } else { (..self.end + 1).get_mut(slice) }
         }
         #[inline]
         unsafe fn get_unchecked(self, slice: &str) -> &Self::Output {
@@ -2069,14 +2069,14 @@ mod traits {
         }
         #[inline]
         fn index(self, slice: &str) -> &Self::Output {
-            if self.end == usize::max_value() {
+            if self.end == usize::MAX {
                 str_index_overflow_fail();
             }
             (..self.end + 1).index(slice)
         }
         #[inline]
         fn index_mut(self, slice: &mut str) -> &mut Self::Output {
-            if self.end == usize::max_value() {
+            if self.end == usize::MAX {
                 str_index_overflow_fail();
             }
             (..self.end + 1).index_mut(slice)
diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs
index f61793a3bca81..981ced34a809c 100644
--- a/src/libcore/tests/num/mod.rs
+++ b/src/libcore/tests/num/mod.rs
@@ -140,8 +140,8 @@ macro_rules! test_impl_from {
     ($fn_name: ident, $Small: ty, $Large: ty) => {
         #[test]
         fn $fn_name() {
-            let small_max = <$Small>::max_value();
-            let small_min = <$Small>::min_value();
+            let small_max = <$Small>::MAX;
+            let small_min = <$Small>::MIN;
             let large_max: $Large = small_max.into();
             let large_min: $Large = small_min.into();
             assert_eq!(large_max as $Small, small_max);
@@ -250,8 +250,8 @@ macro_rules! test_impl_try_from_always_ok {
     ($fn_name:ident, $source:ty, $target: ty) => {
         #[test]
         fn $fn_name() {
-            let max = <$source>::max_value();
-            let min = <$source>::min_value();
+            let max = <$source>::MAX;
+            let min = <$source>::MIN;
             let zero: $source = 0;
             assert_eq!(<$target as TryFrom<$source>>::try_from(max).unwrap(), max as $target);
             assert_eq!(<$target as TryFrom<$source>>::try_from(min).unwrap(), min as $target);
@@ -363,8 +363,8 @@ macro_rules! test_impl_try_from_signed_to_unsigned_upper_ok {
     ($fn_name:ident, $source:ty, $target:ty) => {
         #[test]
         fn $fn_name() {
-            let max = <$source>::max_value();
-            let min = <$source>::min_value();
+            let max = <$source>::MAX;
+            let min = <$source>::MIN;
             let zero: $source = 0;
             let neg_one: $source = -1;
             assert_eq!(<$target as TryFrom<$source>>::try_from(max).unwrap(), max as $target);
@@ -428,8 +428,8 @@ macro_rules! test_impl_try_from_unsigned_to_signed_upper_err {
     ($fn_name:ident, $source:ty, $target:ty) => {
         #[test]
         fn $fn_name() {
-            let max = <$source>::max_value();
-            let min = <$source>::min_value();
+            let max = <$source>::MAX;
+            let min = <$source>::MIN;
             let zero: $source = 0;
             assert!(<$target as TryFrom<$source>>::try_from(max).is_err());
             assert_eq!(<$target as TryFrom<$source>>::try_from(min).unwrap(), min as $target);
@@ -489,11 +489,11 @@ macro_rules! test_impl_try_from_same_sign_err {
     ($fn_name:ident, $source:ty, $target:ty) => {
         #[test]
         fn $fn_name() {
-            let max = <$source>::max_value();
-            let min = <$source>::min_value();
+            let max = <$source>::MAX;
+            let min = <$source>::MIN;
             let zero: $source = 0;
-            let t_max = <$target>::max_value();
-            let t_min = <$target>::min_value();
+            let t_max = <$target>::MAX;
+            let t_min = <$target>::MIN;
             assert!(<$target as TryFrom<$source>>::try_from(max).is_err());
             if min != 0 {
                 assert!(<$target as TryFrom<$source>>::try_from(min).is_err());
@@ -578,11 +578,11 @@ macro_rules! test_impl_try_from_signed_to_unsigned_err {
     ($fn_name:ident, $source:ty, $target:ty) => {
         #[test]
         fn $fn_name() {
-            let max = <$source>::max_value();
-            let min = <$source>::min_value();
+            let max = <$source>::MAX;
+            let min = <$source>::MIN;
             let zero: $source = 0;
-            let t_max = <$target>::max_value();
-            let t_min = <$target>::min_value();
+            let t_max = <$target>::MAX;
+            let t_min = <$target>::MIN;
             assert!(<$target as TryFrom<$source>>::try_from(max).is_err());
             assert!(<$target as TryFrom<$source>>::try_from(min).is_err());
             assert_eq!(<$target as TryFrom<$source>>::try_from(zero).unwrap(), zero as $target);
diff --git a/src/libcore/tests/ptr.rs b/src/libcore/tests/ptr.rs
index a008b3319f39a..9fea34d668fcc 100644
--- a/src/libcore/tests/ptr.rs
+++ b/src/libcore/tests/ptr.rs
@@ -357,7 +357,7 @@ fn align_offset_weird_strides() {
 
     unsafe fn test_weird_stride<T>(ptr: *const T, align: usize) -> bool {
         let numptr = ptr as usize;
-        let mut expected = usize::max_value();
+        let mut expected = usize::MAX;
         // Naive but definitely correct way to find the *first* aligned element of stride::<T>.
         for el in 0..align {
             if (numptr + el * ::std::mem::size_of::<T>()) % align == 0 {
diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs
index cc274b4aecf54..ada895fa43fcb 100644
--- a/src/libcore/tests/slice.rs
+++ b/src/libcore/tests/slice.rs
@@ -1685,8 +1685,8 @@ fn test_copy_within_panics_src_inverted() {
 #[should_panic(expected = "attempted to index slice up to maximum usize")]
 fn test_copy_within_panics_src_out_of_bounds() {
     let mut bytes = *b"Hello, World!";
-    // an inclusive range ending at usize::max_value() would make src_end overflow
-    bytes.copy_within(usize::max_value()..=usize::max_value(), 0);
+    // an inclusive range ending at usize::MAX would make src_end overflow
+    bytes.copy_within(usize::MAX..=usize::MAX, 0);
 }
 
 #[test]
diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs
index a06b23367e6da..886adc61c2b38 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 9b0399e22c59c..e1dc3488825e6 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 5f599034e7d4d..ba07b8a44387a 100644
--- a/src/librustc/ty/layout.rs
+++ b/src/librustc/ty/layout.rs
@@ -990,7 +990,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) {
@@ -1010,7 +1010,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 8dafe407ed9c2..35996bb5b3731 100644
--- a/src/librustc/ty/print/pretty.rs
+++ b/src/librustc/ty/print/pretty.rs
@@ -896,7 +896,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/util.rs b/src/librustc/ty/util.rs
index 15fae10236dbc..ed0b5f8e3eb66 100644
--- a/src/librustc/ty/util.rs
+++ b/src/librustc/ty/util.rs
@@ -63,9 +63,9 @@ impl<'tcx> Discr<'tcx> {
         if signed {
             let sext = |u| sign_extend(u, size) as i128;
             let min = sext(1_u128 << (bit_size - 1));
-            let max = i128::max_value() >> shift;
+            let max = i128::MAX >> shift;
             let val = sext(self.val);
-            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 };
@@ -74,7 +74,7 @@ impl<'tcx> Discr<'tcx> {
             let val = truncate(val, size);
             (Self { val: val as u128, ty: self.ty }, oflo)
         } else {
-            let max = u128::max_value() >> shift;
+            let max = u128::MAX >> shift;
             let val = self.val;
             let oflo = val > max - n;
             let val = if oflo { n - (max - val) - 1 } else { val + n };
diff --git a/src/librustc_apfloat/lib.rs b/src/librustc_apfloat/lib.rs
index d08ff60a366cc..c0a80883b56ec 100644
--- a/src/librustc_apfloat/lib.rs
+++ b/src/librustc_apfloat/lib.rs
@@ -132,9 +132,9 @@ impl Neg for Round {
 pub type ExpInt = i16;
 
 // \c ilogb error results.
-pub const IEK_INF: ExpInt = ExpInt::max_value();
-pub const IEK_NAN: ExpInt = ExpInt::min_value();
-pub const IEK_ZERO: ExpInt = ExpInt::min_value() + 1;
+pub const IEK_INF: ExpInt = ExpInt::MAX;
+pub const IEK_NAN: ExpInt = ExpInt::MIN;
+pub const IEK_ZERO: ExpInt = ExpInt::MIN + 1;
 
 #[derive(Copy, Clone, PartialEq, Eq, Debug)]
 pub struct ParseError(pub &'static str);
diff --git a/src/librustc_data_structures/base_n/tests.rs b/src/librustc_data_structures/base_n/tests.rs
index a86f991cd0e0d..b68ef1eb7f4c4 100644
--- a/src/librustc_data_structures/base_n/tests.rs
+++ b/src/librustc_data_structures/base_n/tests.rs
@@ -12,8 +12,8 @@ fn test_encode() {
         test(35, base);
         test(36, base);
         test(37, base);
-        test(u64::max_value() as u128, base);
-        test(u128::max_value(), base);
+        test(u64::MAX as u128, base);
+        test(u128::MAX, base);
 
         for i in 0..1_000 {
             test(i * 983, base);
diff --git a/src/librustc_expand/proc_macro_server.rs b/src/librustc_expand/proc_macro_server.rs
index cf5749f506856..ee89e786ec91b 100644
--- a/src/librustc_expand/proc_macro_server.rs
+++ b/src/librustc_expand/proc_macro_server.rs
@@ -579,10 +579,10 @@ impl server::Literal for Rustc<'_> {
         };
 
         // Bounds check the values, preventing addition overflow and OOB spans.
-        if start > u32::max_value() as usize
-            || end > u32::max_value() as usize
-            || (u32::max_value() - start as u32) < span.lo().to_u32()
-            || (u32::max_value() - end as u32) < span.lo().to_u32()
+        if start > u32::MAX as usize
+            || end > u32::MAX as usize
+            || (u32::MAX - start as u32) < span.lo().to_u32()
+            || (u32::MAX - end as u32) < span.lo().to_u32()
             || start >= end
             || end > length
         {
diff --git a/src/librustc_lexer/src/unescape.rs b/src/librustc_lexer/src/unescape.rs
index 4f5e03d008c99..f8f20d7f3831c 100644
--- a/src/librustc_lexer/src/unescape.rs
+++ b/src/librustc_lexer/src/unescape.rs
@@ -345,7 +345,7 @@ where
 
 fn byte_from_char(c: char) -> u8 {
     let res = c as u32;
-    assert!(res <= u8::max_value() as u32, "guaranteed because of Mode::Byte(Str)");
+    assert!(res <= u8::MAX as u32, "guaranteed because of Mode::Byte(Str)");
     res as u8
 }
 
diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs
index 7944c88c7cbd8..6c3aee1dafef1 100644
--- a/src/librustc_lint/types.rs
+++ b/src/librustc_lint/types.rs
@@ -111,23 +111,23 @@ fn lint_overflowing_range_endpoint<'a, 'tcx>(
 // warnings are consistent between 32- and 64-bit platforms.
 fn int_ty_range(int_ty: ast::IntTy) -> (i128, i128) {
     match int_ty {
-        ast::IntTy::Isize => (i64::min_value() as i128, i64::max_value() as i128),
-        ast::IntTy::I8 => (i8::min_value() as i64 as i128, i8::max_value() as i128),
-        ast::IntTy::I16 => (i16::min_value() as i64 as i128, i16::max_value() as i128),
-        ast::IntTy::I32 => (i32::min_value() as i64 as i128, i32::max_value() as i128),
-        ast::IntTy::I64 => (i64::min_value() as i128, i64::max_value() as i128),
-        ast::IntTy::I128 => (i128::min_value() as i128, i128::max_value()),
+        ast::IntTy::Isize => (i64::MIN as i128, i64::MAX as i128),
+        ast::IntTy::I8 => (i8::MIN as i64 as i128, i8::MAX as i128),
+        ast::IntTy::I16 => (i16::MIN as i64 as i128, i16::MAX as i128),
+        ast::IntTy::I32 => (i32::MIN as i64 as i128, i32::MAX as i128),
+        ast::IntTy::I64 => (i64::MIN as i128, i64::MAX as i128),
+        ast::IntTy::I128 => (i128::MIN as i128, i128::MAX),
     }
 }
 
 fn uint_ty_range(uint_ty: ast::UintTy) -> (u128, u128) {
     match uint_ty {
-        ast::UintTy::Usize => (u64::min_value() as u128, u64::max_value() as u128),
-        ast::UintTy::U8 => (u8::min_value() as u128, u8::max_value() as u128),
-        ast::UintTy::U16 => (u16::min_value() as u128, u16::max_value() as u128),
-        ast::UintTy::U32 => (u32::min_value() as u128, u32::max_value() as u128),
-        ast::UintTy::U64 => (u64::min_value() as u128, u64::max_value() as u128),
-        ast::UintTy::U128 => (u128::min_value(), u128::max_value()),
+        ast::UintTy::Usize => (u64::MIN as u128, u64::MAX as u128),
+        ast::UintTy::U8 => (u8::MIN as u128, u8::MAX as u128),
+        ast::UintTy::U16 => (u16::MIN as u128, u16::MAX as u128),
+        ast::UintTy::U32 => (u32::MIN as u128, u32::MAX as u128),
+        ast::UintTy::U64 => (u64::MIN as u128, u64::MAX as u128),
+        ast::UintTy::U128 => (u128::MIN, u128::MAX),
     }
 }
 
diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs
index f95801d6fb15a..cb88b5e66bd41 100644
--- a/src/librustc_metadata/creader.rs
+++ b/src/librustc_metadata/creader.rs
@@ -991,7 +991,7 @@ impl<'a> CrateLoader<'a> {
                 src: ExternCrateSource::Path,
                 span,
                 // to have the least priority in `update_extern_crate`
-                path_len: usize::max_value(),
+                path_len: usize::MAX,
                 dependency_of: LOCAL_CRATE,
             },
         );
diff --git a/src/librustc_mir/build/matches/simplify.rs b/src/librustc_mir/build/matches/simplify.rs
index bbb555a58e69f..af17b66ec68dc 100644
--- a/src/librustc_mir/build/matches/simplify.rs
+++ b/src/librustc_mir/build/matches/simplify.rs
@@ -111,13 +111,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
                     }
                     ty::Int(ity) => {
                         let size = Integer::from_attr(&tcx, SignedInt(ity)).size();
-                        let max = truncate(u128::max_value(), size);
+                        let max = truncate(u128::MAX, size);
                         let bias = 1u128 << (size.bits() - 1);
                         (Some((0, max, size)), bias)
                     }
                     ty::Uint(uty) => {
                         let size = Integer::from_attr(&tcx, UnsignedInt(uty)).size();
-                        let max = truncate(u128::max_value(), size);
+                        let max = truncate(u128::MAX, size);
                         (Some((0, max, size)), 0)
                     }
                     _ => (None, 0),
diff --git a/src/librustc_mir/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs
index 61d2eceb30877..ffeb5e27ef191 100644
--- a/src/librustc_mir/hair/pattern/_match.rs
+++ b/src/librustc_mir/hair/pattern/_match.rs
@@ -1333,7 +1333,7 @@ fn all_constructors<'a, 'tcx>(
         }
         ty::Uint(uty) => {
             let size = Integer::from_attr(&cx.tcx, UnsignedInt(uty)).size();
-            let max = truncate(u128::max_value(), size);
+            let max = truncate(u128::MAX, size);
             vec![make_range(0, max)]
         }
         _ => {
diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs
index b075e8ea383e1..bf4df181878eb 100644
--- a/src/librustc_mir/interpret/intrinsics.rs
+++ b/src/librustc_mir/interpret/intrinsics.rs
@@ -205,7 +205,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 {
diff --git a/src/librustc_mir/interpret/validity.rs b/src/librustc_mir/interpret/validity.rs
index b55f66dc75124..810eac46aaf07 100644
--- a/src/librustc_mir/interpret/validity.rs
+++ b/src/librustc_mir/interpret/validity.rs
@@ -508,7 +508,7 @@ impl<'rt, 'mir, 'tcx, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
         // Determine the allowed range
         let (lo, hi) = layout.valid_range.clone().into_inner();
         // `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) {
diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs
index 84cb3f7181996..f60408334b686 100644
--- a/src/librustc_resolve/late.rs
+++ b/src/librustc_resolve/late.rs
@@ -1778,7 +1778,7 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
             //
             // use std::u8; // bring module u8 in scope
             // fn f() -> u8 { // OK, resolves to primitive u8, not to std::u8
-            //     u8::max_value() // OK, resolves to associated function <u8>::max_value,
+            //     u8::MAX // OK, resolves to associated function <u8>::max_value,
             //                     // not to non-existent std::u8::max_value
             // }
             //
diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs
index 1f72d1dd847b9..5b4f25f8df85f 100644
--- a/src/librustc_save_analysis/lib.rs
+++ b/src/librustc_save_analysis/lib.rs
@@ -1086,7 +1086,7 @@ fn id_from_node_id(id: NodeId, scx: &SaveContext<'_, '_>) -> rls_data::Id {
 }
 
 fn null_id() -> rls_data::Id {
-    rls_data::Id { krate: u32::max_value(), index: u32::max_value() }
+    rls_data::Id { krate: u32::MAX, index: u32::MAX }
 }
 
 fn lower_attributes(attrs: Vec<Attribute>, scx: &SaveContext<'_, '_>) -> Vec<rls_data::Attribute> {
diff --git a/src/librustc_span/lib.rs b/src/librustc_span/lib.rs
index a58c12f23508a..af7c5e6bd8a7e 100644
--- a/src/librustc_span/lib.rs
+++ b/src/librustc_span/lib.rs
@@ -1097,7 +1097,7 @@ impl SourceFile {
             hasher.finish::<u128>()
         };
         let end_pos = start_pos.to_usize() + src.len();
-        if end_pos > u32::max_value() as usize {
+        if end_pos > u32::MAX as usize {
             return Err(OffsetOverflowError);
         }
 
diff --git a/src/librustc_span/source_map.rs b/src/librustc_span/source_map.rs
index 0b9b9fe7887f2..6196b8579b366 100644
--- a/src/librustc_span/source_map.rs
+++ b/src/librustc_span/source_map.rs
@@ -749,9 +749,7 @@ impl SourceMap {
 
         // Disregard indexes that are at the start or end of their spans, they can't fit bigger
         // characters.
-        if (!forwards && end_index == usize::min_value())
-            || (forwards && start_index == usize::max_value())
-        {
+        if (!forwards && end_index == usize::MIN) || (forwards && start_index == usize::MAX) {
             debug!("find_width_of_character_at_span: start or end of span, cannot be multibyte");
             return 1;
         }
diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs
index 9e6849ba5bc39..751809ca29e2f 100644
--- a/src/libstd/io/buffered.rs
+++ b/src/libstd/io/buffered.rs
@@ -339,7 +339,7 @@ impl<R: Seek> Seek for BufReader<R> {
             // it should be safe to assume that remainder fits within an i64 as the alternative
             // means we managed to allocate 8 exbibytes and that's absurd.
             // But it's not out of the realm of possibility for some weird underlying reader to
-            // support seeking by i64::min_value() so we need to handle underflow when subtracting
+            // support seeking by i64::MIN so we need to handle underflow when subtracting
             // remainder.
             if let Some(offset) = n.checked_sub(remainder) {
                 result = self.inner.seek(SeekFrom::Current(offset))?;
@@ -1222,7 +1222,7 @@ mod tests {
                         self.pos = self.pos.wrapping_add(n as u64);
                     }
                     SeekFrom::End(n) => {
-                        self.pos = u64::max_value().wrapping_add(n as u64);
+                        self.pos = u64::MAX.wrapping_add(n as u64);
                     }
                 }
                 Ok(self.pos)
@@ -1231,11 +1231,11 @@ mod tests {
 
         let mut reader = BufReader::with_capacity(5, PositionReader { pos: 0 });
         assert_eq!(reader.fill_buf().ok(), Some(&[0, 1, 2, 3, 4][..]));
-        assert_eq!(reader.seek(SeekFrom::End(-5)).ok(), Some(u64::max_value() - 5));
+        assert_eq!(reader.seek(SeekFrom::End(-5)).ok(), Some(u64::MAX - 5));
         assert_eq!(reader.fill_buf().ok().map(|s| s.len()), Some(5));
         // the following seek will require two underlying seeks
         let expected = 9223372036854775802;
-        assert_eq!(reader.seek(SeekFrom::Current(i64::min_value())).ok(), Some(expected));
+        assert_eq!(reader.seek(SeekFrom::Current(i64::MIN)).ok(), Some(expected));
         assert_eq!(reader.fill_buf().ok().map(|s| s.len()), Some(5));
         // seeking to 0 should empty the buffer.
         assert_eq!(reader.seek(SeekFrom::Current(0)).ok(), Some(expected));
@@ -1273,7 +1273,7 @@ mod tests {
         // The following seek will require two underlying seeks.  The first will
         // succeed but the second will fail.  This should still invalidate the
         // buffer.
-        assert!(reader.seek(SeekFrom::Current(i64::min_value())).is_err());
+        assert!(reader.seek(SeekFrom::Current(i64::MIN)).is_err());
         assert_eq!(reader.buffer().len(), 0);
     }
 
diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs
index 9787cbb556bd2..960cca89a104c 100644
--- a/src/libstd/io/cursor.rs
+++ b/src/libstd/io/cursor.rs
@@ -939,7 +939,7 @@ mod tests {
     #[cfg(target_pointer_width = "32")]
     fn vec_seek_and_write_past_usize_max() {
         let mut c = Cursor::new(Vec::new());
-        c.set_position(<usize>::max_value() as u64 + 1);
+        c.set_position(<usize>::MAX as u64 + 1);
         assert!(c.write_all(&[1, 2, 3]).is_err());
     }
 
diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs
index e70204d6839fc..d6cc811154f11 100644
--- a/src/libstd/sync/mpsc/mod.rs
+++ b/src/libstd/sync/mpsc/mod.rs
@@ -2176,8 +2176,7 @@ mod tests {
     #[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31
     fn very_long_recv_timeout_wont_panic() {
         let (tx, rx) = channel::<()>();
-        let join_handle =
-            thread::spawn(move || rx.recv_timeout(Duration::from_secs(u64::max_value())));
+        let join_handle = thread::spawn(move || rx.recv_timeout(Duration::from_secs(u64::MAX)));
         thread::sleep(Duration::from_secs(1));
         assert!(tx.send(()).is_ok());
         assert_eq!(join_handle.join().unwrap(), Ok(()));
diff --git a/src/libstd/sys/cloudabi/condvar.rs b/src/libstd/sys/cloudabi/condvar.rs
index 3ba51d77494d4..dabdc0c9b510a 100644
--- a/src/libstd/sys/cloudabi/condvar.rs
+++ b/src/libstd/sys/cloudabi/condvar.rs
@@ -42,7 +42,7 @@ impl Condvar {
             let ret = abi::condvar_signal(
                 condvar as *mut abi::condvar,
                 abi::scope::PRIVATE,
-                abi::nthreads::max_value(),
+                abi::nthreads::MAX,
             );
             assert_eq!(ret, abi::errno::SUCCESS, "Failed to broadcast on condition variable");
         }
diff --git a/src/libstd/sys/hermit/condvar.rs b/src/libstd/sys/hermit/condvar.rs
index 5b7f16ce562b9..b6d417e598fae 100644
--- a/src/libstd/sys/hermit/condvar.rs
+++ b/src/libstd/sys/hermit/condvar.rs
@@ -36,7 +36,7 @@ impl Condvar {
 
     pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
         let nanos = dur.as_nanos();
-        let nanos = cmp::min(i64::max_value() as u128, nanos);
+        let nanos = cmp::min(i64::MAX as u128, nanos);
 
         // add current task to the wait queue
         let _ = abi::add_queue(self.id(), nanos as i64);
diff --git a/src/libstd/sys/unix/android.rs b/src/libstd/sys/unix/android.rs
index 8fc2599f0d762..ea05ee3d7cedf 100644
--- a/src/libstd/sys/unix/android.rs
+++ b/src/libstd/sys/unix/android.rs
@@ -95,7 +95,7 @@ pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {
         match ftruncate64.get() {
             Some(f) => cvt_r(|| f(fd, size as i64)).map(drop),
             None => {
-                if size > i32::max_value() as u64 {
+                if size > i32::MAX as u64 {
                     Err(io::Error::new(io::ErrorKind::InvalidInput, "cannot truncate >2GB"))
                 } else {
                     cvt_r(|| ftruncate(fd, size as i32)).map(drop)
diff --git a/src/libstd/sys/unix/condvar.rs b/src/libstd/sys/unix/condvar.rs
index b4896b7ad7476..9f1847943f326 100644
--- a/src/libstd/sys/unix/condvar.rs
+++ b/src/libstd/sys/unix/condvar.rs
@@ -10,14 +10,10 @@ unsafe impl Send for Condvar {}
 unsafe impl Sync for Condvar {}
 
 const TIMESPEC_MAX: libc::timespec =
-    libc::timespec { tv_sec: <libc::time_t>::max_value(), tv_nsec: 1_000_000_000 - 1 };
+    libc::timespec { tv_sec: <libc::time_t>::MAX, tv_nsec: 1_000_000_000 - 1 };
 
 fn saturating_cast_to_time_t(value: u64) -> libc::time_t {
-    if value > <libc::time_t>::max_value() as u64 {
-        <libc::time_t>::max_value()
-    } else {
-        value as libc::time_t
-    }
+    if value > <libc::time_t>::MAX as u64 { <libc::time_t>::MAX } else { value as libc::time_t }
 }
 
 impl Condvar {
diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs
index e0e6e02a443e1..bc854831da25a 100644
--- a/src/libstd/sys/unix/ext/net.rs
+++ b/src/libstd/sys/unix/ext/net.rs
@@ -1061,7 +1061,7 @@ impl<'a> Iterator for Incoming<'a> {
     }
 
     fn size_hint(&self) -> (usize, Option<usize>) {
-        (usize::max_value(), None)
+        (usize::MAX, None)
     }
 }
 
diff --git a/src/libstd/sys/unix/fd.rs b/src/libstd/sys/unix/fd.rs
index 8a99836912a33..3aea5f00392ce 100644
--- a/src/libstd/sys/unix/fd.rs
+++ b/src/libstd/sys/unix/fd.rs
@@ -23,11 +23,7 @@ fn max_len() -> usize {
     // intentionally showing odd behavior by rejecting any read with a size
     // larger than or equal to INT_MAX. To handle both of these the read
     // size is capped on both platforms.
-    if cfg!(target_os = "macos") {
-        <c_int>::max_value() as usize - 1
-    } else {
-        <ssize_t>::max_value() as usize
-    }
+    if cfg!(target_os = "macos") { <c_int>::MAX as usize - 1 } else { <ssize_t>::MAX as usize }
 }
 
 impl FileDesc {
@@ -58,7 +54,7 @@ impl FileDesc {
             libc::readv(
                 self.fd,
                 bufs.as_ptr() as *const libc::iovec,
-                cmp::min(bufs.len(), c_int::max_value() as usize) as c_int,
+                cmp::min(bufs.len(), c_int::MAX as usize) as c_int,
             )
         })?;
         Ok(ret as usize)
@@ -110,7 +106,7 @@ impl FileDesc {
             libc::writev(
                 self.fd,
                 bufs.as_ptr() as *const libc::iovec,
-                cmp::min(bufs.len(), c_int::max_value() as usize) as c_int,
+                cmp::min(bufs.len(), c_int::MAX as usize) as c_int,
             )
         })?;
         Ok(ret as usize)
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs
index 2a0519487c7a7..7bd8788162d19 100644
--- a/src/libstd/sys/unix/fs.rs
+++ b/src/libstd/sys/unix/fs.rs
@@ -1180,7 +1180,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
     let mut written = 0u64;
     while written < len {
         let copy_result = if has_copy_file_range {
-            let bytes_to_copy = cmp::min(len - written, usize::max_value() as u64) as usize;
+            let bytes_to_copy = cmp::min(len - written, usize::MAX as u64) as usize;
             let copy_result = unsafe {
                 // We actually don't have to adjust the offsets,
                 // because copy_file_range adjusts the file offset automatically
diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs
index 79b0dc02978f3..d1e34927585c8 100644
--- a/src/libstd/sys/unix/net.rs
+++ b/src/libstd/sys/unix/net.rs
@@ -148,7 +148,7 @@ impl Socket {
                 timeout = 1;
             }
 
-            let timeout = cmp::min(timeout, c_int::max_value() as u64) as c_int;
+            let timeout = cmp::min(timeout, c_int::MAX as u64) as c_int;
 
             match unsafe { libc::poll(&mut pollfd, 1, timeout) } {
                 -1 => {
@@ -273,8 +273,8 @@ impl Socket {
                     ));
                 }
 
-                let secs = if dur.as_secs() > libc::time_t::max_value() as u64 {
-                    libc::time_t::max_value()
+                let secs = if dur.as_secs() > libc::time_t::MAX as u64 {
+                    libc::time_t::MAX
                 } else {
                     dur.as_secs() as libc::time_t
                 };
diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs
index a5b34eeec289e..899a9a8548f5b 100644
--- a/src/libstd/sys/unix/thread.rs
+++ b/src/libstd/sys/unix/thread.rs
@@ -164,7 +164,7 @@ impl Thread {
         unsafe {
             while secs > 0 || nsecs > 0 {
                 let mut ts = libc::timespec {
-                    tv_sec: cmp::min(libc::time_t::max_value() as u64, secs) as libc::time_t,
+                    tv_sec: cmp::min(libc::time_t::MAX as u64, secs) as libc::time_t,
                     tv_nsec: nsecs,
                 };
                 secs -= ts.tv_sec as u64;
diff --git a/src/libstd/sys/vxworks/condvar.rs b/src/libstd/sys/vxworks/condvar.rs
index f2a1d6815290d..5a77966d97468 100644
--- a/src/libstd/sys/vxworks/condvar.rs
+++ b/src/libstd/sys/vxworks/condvar.rs
@@ -10,14 +10,10 @@ unsafe impl Send for Condvar {}
 unsafe impl Sync for Condvar {}
 
 const TIMESPEC_MAX: libc::timespec =
-    libc::timespec { tv_sec: <libc::time_t>::max_value(), tv_nsec: 1_000_000_000 - 1 };
+    libc::timespec { tv_sec: <libc::time_t>::MAX, tv_nsec: 1_000_000_000 - 1 };
 
 fn saturating_cast_to_time_t(value: u64) -> libc::time_t {
-    if value > <libc::time_t>::max_value() as u64 {
-        <libc::time_t>::max_value()
-    } else {
-        value as libc::time_t
-    }
+    if value > <libc::time_t>::MAX as u64 { <libc::time_t>::MAX } else { value as libc::time_t }
 }
 
 impl Condvar {
diff --git a/src/libstd/sys/vxworks/fd.rs b/src/libstd/sys/vxworks/fd.rs
index 65c67dabc1ad0..fbd8bddb0ebdc 100644
--- a/src/libstd/sys/vxworks/fd.rs
+++ b/src/libstd/sys/vxworks/fd.rs
@@ -17,7 +17,7 @@ fn max_len() -> usize {
     // The maximum read limit on most posix-like systems is `SSIZE_MAX`,
     // with the man page quoting that if the count of bytes to read is
     // greater than `SSIZE_MAX` the result is "unspecified".
-    <ssize_t>::max_value() as usize
+    <ssize_t>::MAX as usize
 }
 
 impl FileDesc {
@@ -48,7 +48,7 @@ impl FileDesc {
             libc::readv(
                 self.fd,
                 bufs.as_ptr() as *const libc::iovec,
-                cmp::min(bufs.len(), c_int::max_value() as usize) as c_int,
+                cmp::min(bufs.len(), c_int::MAX as usize) as c_int,
             )
         })?;
         Ok(ret as usize)
@@ -93,7 +93,7 @@ impl FileDesc {
             libc::writev(
                 self.fd,
                 bufs.as_ptr() as *const libc::iovec,
-                cmp::min(bufs.len(), c_int::max_value() as usize) as c_int,
+                cmp::min(bufs.len(), c_int::MAX as usize) as c_int,
             )
         })?;
         Ok(ret as usize)
diff --git a/src/libstd/sys/vxworks/net.rs b/src/libstd/sys/vxworks/net.rs
index 7d4e5624f7e39..f5a02bfbd0854 100644
--- a/src/libstd/sys/vxworks/net.rs
+++ b/src/libstd/sys/vxworks/net.rs
@@ -107,7 +107,7 @@ impl Socket {
                 timeout = 1;
             }
 
-            let timeout = cmp::min(timeout, c_int::max_value() as u64) as c_int;
+            let timeout = cmp::min(timeout, c_int::MAX as u64) as c_int;
 
             match unsafe { libc::poll(&mut pollfd, 1, timeout) } {
                 -1 => {
@@ -210,8 +210,8 @@ impl Socket {
                     ));
                 }
 
-                let secs = if dur.as_secs() > libc::time_t::max_value() as u64 {
-                    libc::time_t::max_value()
+                let secs = if dur.as_secs() > libc::time_t::MAX as u64 {
+                    libc::time_t::MAX
                 } else {
                     dur.as_secs() as libc::time_t
                 };
diff --git a/src/libstd/sys/vxworks/thread.rs b/src/libstd/sys/vxworks/thread.rs
index e0d104b5f3ec9..878be827e2f3c 100644
--- a/src/libstd/sys/vxworks/thread.rs
+++ b/src/libstd/sys/vxworks/thread.rs
@@ -89,7 +89,7 @@ impl Thread {
         unsafe {
             while secs > 0 || nsecs > 0 {
                 let mut ts = libc::timespec {
-                    tv_sec: cmp::min(libc::time_t::max_value() as u64, secs) as libc::time_t,
+                    tv_sec: cmp::min(libc::time_t::MAX as u64, secs) as libc::time_t,
                     tv_nsec: nsecs,
                 };
                 secs -= ts.tv_sec as u64;
diff --git a/src/libstd/sys/wasi/mod.rs b/src/libstd/sys/wasi/mod.rs
index 241d499ca3b2d..64701b33af588 100644
--- a/src/libstd/sys/wasi/mod.rs
+++ b/src/libstd/sys/wasi/mod.rs
@@ -64,7 +64,7 @@ pub fn unsupported_err() -> std_io::Error {
 
 pub fn decode_error_kind(errno: i32) -> std_io::ErrorKind {
     use std_io::ErrorKind::*;
-    if errno > u16::max_value() as i32 || errno < 0 {
+    if errno > u16::MAX as i32 || errno < 0 {
         return Other;
     }
     match errno as u16 {
diff --git a/src/libstd/sys/wasi/thread.rs b/src/libstd/sys/wasi/thread.rs
index 0986759b89b7c..0d39b1cec328c 100644
--- a/src/libstd/sys/wasi/thread.rs
+++ b/src/libstd/sys/wasi/thread.rs
@@ -25,7 +25,7 @@ impl Thread {
 
     pub fn sleep(dur: Duration) {
         let nanos = dur.as_nanos();
-        assert!(nanos <= u64::max_value() as u128);
+        assert!(nanos <= u64::MAX as u128);
 
         const USERDATA: wasi::Userdata = 0x0123_45678;
 
diff --git a/src/libstd/sys/wasm/condvar_atomics.rs b/src/libstd/sys/wasm/condvar_atomics.rs
index a4021c0ee8380..1859cdd5a0ed8 100644
--- a/src/libstd/sys/wasm/condvar_atomics.rs
+++ b/src/libstd/sys/wasm/condvar_atomics.rs
@@ -48,7 +48,7 @@ impl Condvar {
     #[inline]
     pub unsafe fn notify_all(&self) {
         self.cnt.fetch_add(1, SeqCst);
-        wasm32::atomic_notify(self.ptr(), u32::max_value()); // -1 == "wake everyone"
+        wasm32::atomic_notify(self.ptr(), u32::MAX); // -1 == "wake everyone"
     }
 
     pub unsafe fn wait(&self, mutex: &Mutex) {
@@ -72,7 +72,7 @@ impl Condvar {
         let ticket = self.cnt.load(SeqCst) as i32;
         mutex.unlock();
         let nanos = dur.as_nanos();
-        let nanos = cmp::min(i64::max_value() as u128, nanos);
+        let nanos = cmp::min(i64::MAX as u128, nanos);
 
         // If the return value is 2 then a timeout happened, so we return
         // `false` as we weren't actually notified.
diff --git a/src/libstd/sys/wasm/thread.rs b/src/libstd/sys/wasm/thread.rs
index 0e0e78a827670..0a11896a0048f 100644
--- a/src/libstd/sys/wasm/thread.rs
+++ b/src/libstd/sys/wasm/thread.rs
@@ -38,7 +38,7 @@ impl Thread {
         // 2).
         let mut nanos = dur.as_nanos();
         while nanos > 0 {
-            let amt = cmp::min(i64::max_value() as u128, nanos);
+            let amt = cmp::min(i64::MAX as u128, nanos);
             let mut x = 0;
             let val = unsafe { wasm32::i32_atomic_wait(&mut x, 0, amt as i64) };
             debug_assert_eq!(val, 2);
diff --git a/src/libstd/sys/windows/handle.rs b/src/libstd/sys/windows/handle.rs
index f2ad057b6b624..e2ce5ad75c343 100644
--- a/src/libstd/sys/windows/handle.rs
+++ b/src/libstd/sys/windows/handle.rs
@@ -70,7 +70,7 @@ impl RawHandle {
 
     pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
         let mut read = 0;
-        let len = cmp::min(buf.len(), <c::DWORD>::max_value() as usize) as c::DWORD;
+        let len = cmp::min(buf.len(), <c::DWORD>::MAX as usize) as c::DWORD;
         let res = cvt(unsafe {
             c::ReadFile(self.0, buf.as_mut_ptr() as c::LPVOID, len, &mut read, ptr::null_mut())
         });
@@ -94,7 +94,7 @@ impl RawHandle {
 
     pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> {
         let mut read = 0;
-        let len = cmp::min(buf.len(), <c::DWORD>::max_value() as usize) as c::DWORD;
+        let len = cmp::min(buf.len(), <c::DWORD>::MAX as usize) as c::DWORD;
         let res = unsafe {
             let mut overlapped: c::OVERLAPPED = mem::zeroed();
             overlapped.Offset = offset as u32;
@@ -113,7 +113,7 @@ impl RawHandle {
         buf: &mut [u8],
         overlapped: *mut c::OVERLAPPED,
     ) -> io::Result<Option<usize>> {
-        let len = cmp::min(buf.len(), <c::DWORD>::max_value() as usize) as c::DWORD;
+        let len = cmp::min(buf.len(), <c::DWORD>::MAX as usize) as c::DWORD;
         let mut amt = 0;
         let res =
             cvt({ c::ReadFile(self.0, buf.as_ptr() as c::LPVOID, len, &mut amt, overlapped) });
@@ -161,7 +161,7 @@ impl RawHandle {
 
     pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
         let mut amt = 0;
-        let len = cmp::min(buf.len(), <c::DWORD>::max_value() as usize) as c::DWORD;
+        let len = cmp::min(buf.len(), <c::DWORD>::MAX as usize) as c::DWORD;
         cvt(unsafe {
             c::WriteFile(self.0, buf.as_ptr() as c::LPVOID, len, &mut amt, ptr::null_mut())
         })?;
@@ -174,7 +174,7 @@ impl RawHandle {
 
     pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> {
         let mut written = 0;
-        let len = cmp::min(buf.len(), <c::DWORD>::max_value() as usize) as c::DWORD;
+        let len = cmp::min(buf.len(), <c::DWORD>::MAX as usize) as c::DWORD;
         unsafe {
             let mut overlapped: c::OVERLAPPED = mem::zeroed();
             overlapped.Offset = offset as u32;
diff --git a/src/libstd/sys/windows/io.rs b/src/libstd/sys/windows/io.rs
index 9d8018fd5e864..837201a54441b 100644
--- a/src/libstd/sys/windows/io.rs
+++ b/src/libstd/sys/windows/io.rs
@@ -11,7 +11,7 @@ pub struct IoSlice<'a> {
 impl<'a> IoSlice<'a> {
     #[inline]
     pub fn new(buf: &'a [u8]) -> IoSlice<'a> {
-        assert!(buf.len() <= c::ULONG::max_value() as usize);
+        assert!(buf.len() <= c::ULONG::MAX as usize);
         IoSlice {
             vec: c::WSABUF {
                 len: buf.len() as c::ULONG,
@@ -48,7 +48,7 @@ pub struct IoSliceMut<'a> {
 impl<'a> IoSliceMut<'a> {
     #[inline]
     pub fn new(buf: &'a mut [u8]) -> IoSliceMut<'a> {
-        assert!(buf.len() <= c::ULONG::max_value() as usize);
+        assert!(buf.len() <= c::ULONG::MAX as usize);
         IoSliceMut {
             vec: c::WSABUF { len: buf.len() as c::ULONG, buf: buf.as_mut_ptr() as *mut c::CHAR },
             _p: PhantomData,
diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs
index b004cd19020f8..ad72a26ba52c7 100644
--- a/src/libstd/sys/windows/mod.rs
+++ b/src/libstd/sys/windows/mod.rs
@@ -251,7 +251,7 @@ pub fn dur2timeout(dur: Duration) -> c::DWORD {
         .checked_mul(1000)
         .and_then(|ms| ms.checked_add((dur.subsec_nanos() as u64) / 1_000_000))
         .and_then(|ms| ms.checked_add(if dur.subsec_nanos() % 1_000_000 > 0 { 1 } else { 0 }))
-        .map(|ms| if ms > <c::DWORD>::max_value() as u64 { c::INFINITE } else { ms as c::DWORD })
+        .map(|ms| if ms > <c::DWORD>::MAX as u64 { c::INFINITE } else { ms as c::DWORD })
         .unwrap_or(c::INFINITE)
 }
 
diff --git a/src/libstd/sys/windows/net.rs b/src/libstd/sys/windows/net.rs
index d8d4fdfce2fe4..0f0c0cd38c15c 100644
--- a/src/libstd/sys/windows/net.rs
+++ b/src/libstd/sys/windows/net.rs
@@ -228,7 +228,7 @@ impl Socket {
     fn recv_with_flags(&self, buf: &mut [u8], flags: c_int) -> io::Result<usize> {
         // On unix when a socket is shut down all further reads return 0, so we
         // do the same on windows to map a shut down socket to returning EOF.
-        let len = cmp::min(buf.len(), i32::max_value() as usize) as i32;
+        let len = cmp::min(buf.len(), i32::MAX as usize) as i32;
         unsafe {
             match c::recv(self.0, buf.as_mut_ptr() as *mut c_void, len, flags) {
                 -1 if c::WSAGetLastError() == c::WSAESHUTDOWN => Ok(0),
@@ -245,7 +245,7 @@ impl Socket {
     pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
         // On unix when a socket is shut down all further reads return 0, so we
         // do the same on windows to map a shut down socket to returning EOF.
-        let len = cmp::min(bufs.len(), c::DWORD::max_value() as usize) as c::DWORD;
+        let len = cmp::min(bufs.len(), c::DWORD::MAX as usize) as c::DWORD;
         let mut nread = 0;
         let mut flags = 0;
         unsafe {
@@ -277,7 +277,7 @@ impl Socket {
     ) -> io::Result<(usize, SocketAddr)> {
         let mut storage: c::SOCKADDR_STORAGE_LH = unsafe { mem::zeroed() };
         let mut addrlen = mem::size_of_val(&storage) as c::socklen_t;
-        let len = cmp::min(buf.len(), <wrlen_t>::max_value() as usize) as wrlen_t;
+        let len = cmp::min(buf.len(), <wrlen_t>::MAX as usize) as wrlen_t;
 
         // On unix when a socket is shut down all further reads return 0, so we
         // do the same on windows to map a shut down socket to returning EOF.
@@ -308,7 +308,7 @@ impl Socket {
     }
 
     pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
-        let len = cmp::min(bufs.len(), c::DWORD::max_value() as usize) as c::DWORD;
+        let len = cmp::min(bufs.len(), c::DWORD::MAX as usize) as c::DWORD;
         let mut nwritten = 0;
         unsafe {
             cvt(c::WSASend(
diff --git a/src/libstd/sys_common/net.rs b/src/libstd/sys_common/net.rs
index c7d4828892c04..2fa35347b6cbc 100644
--- a/src/libstd/sys_common/net.rs
+++ b/src/libstd/sys_common/net.rs
@@ -298,7 +298,7 @@ impl TcpStream {
     }
 
     pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
-        let len = cmp::min(buf.len(), <wrlen_t>::max_value() as usize) as wrlen_t;
+        let len = cmp::min(buf.len(), <wrlen_t>::MAX as usize) as wrlen_t;
         let ret = cvt(unsafe {
             c::send(*self.inner.as_inner(), buf.as_ptr() as *const c_void, len, MSG_NOSIGNAL)
         })?;
@@ -521,7 +521,7 @@ impl UdpSocket {
     }
 
     pub fn send_to(&self, buf: &[u8], dst: &SocketAddr) -> io::Result<usize> {
-        let len = cmp::min(buf.len(), <wrlen_t>::max_value() as usize) as wrlen_t;
+        let len = cmp::min(buf.len(), <wrlen_t>::MAX as usize) as wrlen_t;
         let (dstp, dstlen) = dst.into_inner();
         let ret = cvt(unsafe {
             c::sendto(
@@ -650,7 +650,7 @@ impl UdpSocket {
     }
 
     pub fn send(&self, buf: &[u8]) -> io::Result<usize> {
-        let len = cmp::min(buf.len(), <wrlen_t>::max_value() as usize) as wrlen_t;
+        let len = cmp::min(buf.len(), <wrlen_t>::MAX as usize) as wrlen_t;
         let ret = cvt(unsafe {
             c::send(*self.inner.as_inner(), buf.as_ptr() as *const c_void, len, MSG_NOSIGNAL)
         })?;
diff --git a/src/libstd/time.rs b/src/libstd/time.rs
index 0dce8f810eb13..2086d52567e60 100644
--- a/src/libstd/time.rs
+++ b/src/libstd/time.rs
@@ -686,7 +686,7 @@ mod tests {
 
         // checked_add_duration will not panic on overflow
         let mut maybe_t = Some(Instant::now());
-        let max_duration = Duration::from_secs(u64::max_value());
+        let max_duration = Duration::from_secs(u64::MAX);
         // in case `Instant` can store `>= now + max_duration`.
         for _ in 0..2 {
             maybe_t = maybe_t.and_then(|t| t.checked_add(max_duration));
@@ -766,7 +766,7 @@ mod tests {
 
         // checked_add_duration will not panic on overflow
         let mut maybe_t = Some(SystemTime::UNIX_EPOCH);
-        let max_duration = Duration::from_secs(u64::max_value());
+        let max_duration = Duration::from_secs(u64::MAX);
         // in case `SystemTime` can store `>= UNIX_EPOCH + max_duration`.
         for _ in 0..2 {
             maybe_t = maybe_t.and_then(|t| t.checked_add(max_duration));
diff --git a/src/test/run-fail/issue-44216-add-instant.rs b/src/test/run-fail/issue-44216-add-instant.rs
index 76ad0a3d41bf8..51a2f1ab13f2c 100644
--- a/src/test/run-fail/issue-44216-add-instant.rs
+++ b/src/test/run-fail/issue-44216-add-instant.rs
@@ -4,5 +4,5 @@ use std::time::{Instant, Duration};
 
 fn main() {
     let now = Instant::now();
-    let _ = now + Duration::from_secs(u64::max_value());
+    let _ = now + Duration::from_secs(u64::MAX);
 }
diff --git a/src/test/run-fail/issue-44216-add-system-time.rs b/src/test/run-fail/issue-44216-add-system-time.rs
index aa861f7d5993e..b261026300f80 100644
--- a/src/test/run-fail/issue-44216-add-system-time.rs
+++ b/src/test/run-fail/issue-44216-add-system-time.rs
@@ -4,5 +4,5 @@ use std::time::{Duration, SystemTime};
 
 fn main() {
     let now = SystemTime::now();
-    let _ = now + Duration::from_secs(u64::max_value());
+    let _ = now + Duration::from_secs(u64::MAX);
 }
diff --git a/src/test/run-fail/issue-44216-sub-instant.rs b/src/test/run-fail/issue-44216-sub-instant.rs
index 8bc1f47ae2d96..f39d75f75699b 100644
--- a/src/test/run-fail/issue-44216-sub-instant.rs
+++ b/src/test/run-fail/issue-44216-sub-instant.rs
@@ -4,5 +4,5 @@ use std::time::{Instant, Duration};
 
 fn main() {
     let now = Instant::now();
-    let _ = now - Duration::from_secs(u64::max_value());
+    let _ = now - Duration::from_secs(u64::MAX);
 }
diff --git a/src/test/run-fail/issue-44216-sub-system-time.rs b/src/test/run-fail/issue-44216-sub-system-time.rs
index 37ab0e7c3f99f..d9f2f75251709 100644
--- a/src/test/run-fail/issue-44216-sub-system-time.rs
+++ b/src/test/run-fail/issue-44216-sub-system-time.rs
@@ -4,5 +4,5 @@ use std::time::{Duration, SystemTime};
 
 fn main() {
     let now = SystemTime::now();
-    let _ = now - Duration::from_secs(u64::max_value());
+    let _ = now - Duration::from_secs(u64::MAX);
 }
diff --git a/src/test/ui/consts/const-eval/shift_overflow.rs b/src/test/ui/consts/const-eval/shift_overflow.rs
index f7d0f6bd96144..e843584b69bb5 100644
--- a/src/test/ui/consts/const-eval/shift_overflow.rs
+++ b/src/test/ui/consts/const-eval/shift_overflow.rs
@@ -1,6 +1,6 @@
 enum Foo {
     // test that we detect overflows for non-u32 discriminants
-    X = 1 << ((u32::max_value() as u64) + 1), //~ ERROR E0080
+    X = 1 << ((u32::MAX as u64) + 1), //~ ERROR E0080
     Y = 42,
 }
 
diff --git a/src/test/ui/consts/const-eval/shift_overflow.stderr b/src/test/ui/consts/const-eval/shift_overflow.stderr
index 5db231cd5b0df..58e568ee1aa8b 100644
--- a/src/test/ui/consts/const-eval/shift_overflow.stderr
+++ b/src/test/ui/consts/const-eval/shift_overflow.stderr
@@ -1,7 +1,7 @@
 error[E0080]: evaluation of constant value failed
   --> $DIR/shift_overflow.rs:3:9
    |
-LL |     X = 1 << ((u32::max_value() as u64) + 1),
+LL |     X = 1 << ((u32::MAX as u64) + 1),
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to shift left with overflow
 
 error: aborting due to previous error
diff --git a/src/test/ui/consts/const-eval/ub-wide-ptr.rs b/src/test/ui/consts/const-eval/ub-wide-ptr.rs
index a5c2a57c6c886..de59f78985ffe 100644
--- a/src/test/ui/consts/const-eval/ub-wide-ptr.rs
+++ b/src/test/ui/consts/const-eval/ub-wide-ptr.rs
@@ -128,7 +128,7 @@ const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { BoolTransmute
 // # raw slice
 const RAW_SLICE_VALID: *const [u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 1 } }.raw_slice}; // ok
 const RAW_SLICE_TOO_LONG: *const [u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.raw_slice}; // ok because raw
-const RAW_SLICE_MUCH_TOO_LONG: *const [u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: usize::max_value() } }.raw_slice}; // ok because raw
+const RAW_SLICE_MUCH_TOO_LONG: *const [u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: usize::MAX } }.raw_slice}; // ok because raw
 const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe { SliceTransmute { addr: 42 }.raw_slice};
 //~^ ERROR it is undefined behavior to use this value
 
diff --git a/src/test/ui/consts/const-int-conversion-rpass.rs b/src/test/ui/consts/const-int-conversion-rpass.rs
index d52dbbae1e7b5..a09019b95613d 100644
--- a/src/test/ui/consts/const-int-conversion-rpass.rs
+++ b/src/test/ui/consts/const-int-conversion-rpass.rs
@@ -8,13 +8,13 @@ const FROM_LE_BYTES: i32 = i32::from_le_bytes([0x12, 0x34, 0x56, 0x78]);
 const FROM_NE_BYTES: i32 = i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0]));
 const TO_BE_BYTES: [u8; 4] = 0x12_34_56_78_i32.to_be_bytes();
 const TO_LE_BYTES: [u8; 4] = 0x12_34_56_78_i32.to_le_bytes();
-const TO_NE_BYTES: [u8; 4] = i32::min_value().to_be().to_ne_bytes();
+const TO_NE_BYTES: [u8; 4] = i32::MIN.to_be().to_ne_bytes();
 
 fn main() {
     assert_eq!(REVERSE, 0x1e6a2c48);
     assert_eq!(FROM_BE_BYTES, 0x12_34_56_78);
     assert_eq!(FROM_LE_BYTES, 0x78_56_34_12);
-    assert_eq!(FROM_NE_BYTES, i32::min_value());
+    assert_eq!(FROM_NE_BYTES, i32::MIN);
     assert_eq!(TO_BE_BYTES, [0x12, 0x34, 0x56, 0x78]);
     assert_eq!(TO_LE_BYTES, [0x78, 0x56, 0x34, 0x12]);
     assert_eq!(TO_NE_BYTES, [0x80, 0, 0, 0]);
diff --git a/src/test/ui/consts/const-int-conversion.rs b/src/test/ui/consts/const-int-conversion.rs
index b80e616eae77e..5a05a2b35937a 100644
--- a/src/test/ui/consts/const-int-conversion.rs
+++ b/src/test/ui/consts/const-int-conversion.rs
@@ -11,6 +11,6 @@ fn main() {
         //~^ ERROR temporary value dropped while borrowed
     let c: &'static [u8] = &(0x12_34_56_78_i32.to_le_bytes());
         //~^ ERROR temporary value dropped while borrowed
-    let d: &'static [u8] = &(i32::min_value().to_be().to_ne_bytes());
+    let d: &'static [u8] = &(i32::MIN.to_be().to_ne_bytes());
         //~^ ERROR temporary value dropped while borrowed
 }
diff --git a/src/test/ui/consts/const-int-conversion.stderr b/src/test/ui/consts/const-int-conversion.stderr
index 237f9627219bd..6840e39673572 100644
--- a/src/test/ui/consts/const-int-conversion.stderr
+++ b/src/test/ui/consts/const-int-conversion.stderr
@@ -67,7 +67,7 @@ LL | }
 error[E0716]: temporary value dropped while borrowed
   --> $DIR/const-int-conversion.rs:14:29
    |
-LL |     let d: &'static [u8] = &(i32::min_value().to_be().to_ne_bytes());
+LL |     let d: &'static [u8] = &(i32::MIN.to_be().to_ne_bytes());
    |            -------------    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
    |            |
    |            type annotation requires that borrow lasts for `'static`
diff --git a/src/test/ui/consts/const-int-overflowing-rpass.rs b/src/test/ui/consts/const-int-overflowing-rpass.rs
index 9be87a6447cda..eecb88becabca 100644
--- a/src/test/ui/consts/const-int-overflowing-rpass.rs
+++ b/src/test/ui/consts/const-int-overflowing-rpass.rs
@@ -1,7 +1,7 @@
 // run-pass
 
 const ADD_A: (u32, bool) = 5u32.overflowing_add(2);
-const ADD_B: (u32, bool) = u32::max_value().overflowing_add(1);
+const ADD_B: (u32, bool) = u32::MAX.overflowing_add(1);
 
 const SUB_A: (u32, bool) = 5u32.overflowing_sub(2);
 const SUB_B: (u32, bool) = 0u32.overflowing_sub(1);
@@ -20,14 +20,14 @@ const NEG_B: (u32, bool) = core::u32::MAX.overflowing_neg();
 
 const ABS_POS: (i32, bool) = 10i32.overflowing_abs();
 const ABS_NEG: (i32, bool) = (-10i32).overflowing_abs();
-const ABS_MIN: (i32, bool) = i32::min_value().overflowing_abs();
+const ABS_MIN: (i32, bool) = i32::MIN.overflowing_abs();
 
 fn main() {
     assert_eq!(ADD_A, (7, false));
     assert_eq!(ADD_B, (0, true));
 
     assert_eq!(SUB_A, (3, false));
-    assert_eq!(SUB_B, (u32::max_value(), true));
+    assert_eq!(SUB_B, (u32::MAX, true));
 
     assert_eq!(MUL_A, (10, false));
     assert_eq!(MUL_B, (1410065408, true));
@@ -43,5 +43,5 @@ fn main() {
 
     assert_eq!(ABS_POS, (10, false));
     assert_eq!(ABS_NEG, (10, false));
-    assert_eq!(ABS_MIN, (i32::min_value(), true));
+    assert_eq!(ABS_MIN, (i32::MIN, true));
 }
diff --git a/src/test/ui/consts/const-int-saturating-arith.rs b/src/test/ui/consts/const-int-saturating-arith.rs
index d0a3eccd17763..4718120a51bd3 100644
--- a/src/test/ui/consts/const-int-saturating-arith.rs
+++ b/src/test/ui/consts/const-int-saturating-arith.rs
@@ -2,33 +2,33 @@
 #![feature(const_saturating_int_methods)]
 
 const INT_U32_NO: u32 = (42 as u32).saturating_add(2);
-const INT_U32: u32 = u32::max_value().saturating_add(1);
-const INT_U128: u128 = u128::max_value().saturating_add(1);
-const INT_I128: i128 = i128::max_value().saturating_add(1);
-const INT_I128_NEG: i128 = i128::min_value().saturating_add(-1);
+const INT_U32: u32 = u32::MAX.saturating_add(1);
+const INT_U128: u128 = u128::MAX.saturating_add(1);
+const INT_I128: i128 = i128::MAX.saturating_add(1);
+const INT_I128_NEG: i128 = i128::MIN.saturating_add(-1);
 
 const INT_U32_NO_SUB: u32 = (42 as u32).saturating_sub(2);
 const INT_U32_SUB: u32 = (1 as u32).saturating_sub(2);
 const INT_I32_NO_SUB: i32 = (-42 as i32).saturating_sub(2);
-const INT_I32_NEG_SUB: i32 = i32::min_value().saturating_sub(1);
-const INT_I32_POS_SUB: i32 = i32::max_value().saturating_sub(-1);
+const INT_I32_NEG_SUB: i32 = i32::MIN.saturating_sub(1);
+const INT_I32_POS_SUB: i32 = i32::MAX.saturating_sub(-1);
 const INT_U128_SUB: u128 = (0 as u128).saturating_sub(1);
-const INT_I128_NEG_SUB: i128 = i128::min_value().saturating_sub(1);
-const INT_I128_POS_SUB: i128 = i128::max_value().saturating_sub(-1);
+const INT_I128_NEG_SUB: i128 = i128::MIN.saturating_sub(1);
+const INT_I128_POS_SUB: i128 = i128::MAX.saturating_sub(-1);
 
 fn main() {
     assert_eq!(INT_U32_NO, 44);
-    assert_eq!(INT_U32, u32::max_value());
-    assert_eq!(INT_U128, u128::max_value());
-    assert_eq!(INT_I128, i128::max_value());
-    assert_eq!(INT_I128_NEG, i128::min_value());
+    assert_eq!(INT_U32, u32::MAX);
+    assert_eq!(INT_U128, u128::MAX);
+    assert_eq!(INT_I128, i128::MAX);
+    assert_eq!(INT_I128_NEG, i128::MIN);
 
     assert_eq!(INT_U32_NO_SUB, 40);
     assert_eq!(INT_U32_SUB, 0);
     assert_eq!(INT_I32_NO_SUB, -44);
-    assert_eq!(INT_I32_NEG_SUB, i32::min_value());
-    assert_eq!(INT_I32_POS_SUB, i32::max_value());
+    assert_eq!(INT_I32_NEG_SUB, i32::MIN);
+    assert_eq!(INT_I32_POS_SUB, i32::MAX);
     assert_eq!(INT_U128_SUB, 0);
-    assert_eq!(INT_I128_NEG_SUB, i128::min_value());
-    assert_eq!(INT_I128_POS_SUB, i128::max_value());
+    assert_eq!(INT_I128_NEG_SUB, i128::MIN);
+    assert_eq!(INT_I128_POS_SUB, i128::MAX);
 }
diff --git a/src/test/ui/consts/const-int-wrapping-rpass.rs b/src/test/ui/consts/const-int-wrapping-rpass.rs
index 2bbad99a52a90..225d1e9393db4 100644
--- a/src/test/ui/consts/const-int-wrapping-rpass.rs
+++ b/src/test/ui/consts/const-int-wrapping-rpass.rs
@@ -1,10 +1,10 @@
 // run-pass
 
 const ADD_A: u32 = 200u32.wrapping_add(55);
-const ADD_B: u32 = 200u32.wrapping_add(u32::max_value());
+const ADD_B: u32 = 200u32.wrapping_add(u32::MAX);
 
 const SUB_A: u32 = 100u32.wrapping_sub(100);
-const SUB_B: u32 = 100u32.wrapping_sub(u32::max_value());
+const SUB_B: u32 = 100u32.wrapping_sub(u32::MAX);
 
 const MUL_A: u8 = 10u8.wrapping_mul(12);
 const MUL_B: u8 = 25u8.wrapping_mul(12);
@@ -20,7 +20,7 @@ const NEG_B: u32 = 1234567890u32.wrapping_neg();
 
 const ABS_POS: i32 = 10i32.wrapping_abs();
 const ABS_NEG: i32 = (-10i32).wrapping_abs();
-const ABS_MIN: i32 = i32::min_value().wrapping_abs();
+const ABS_MIN: i32 = i32::MIN.wrapping_abs();
 
 fn main() {
     assert_eq!(ADD_A, 255);
@@ -43,5 +43,5 @@ fn main() {
 
     assert_eq!(ABS_POS, 10);
     assert_eq!(ABS_NEG, 10);
-    assert_eq!(ABS_MIN, i32::min_value());
+    assert_eq!(ABS_MIN, i32::MIN);
 }
diff --git a/src/test/ui/consts/promote_fn_calls_std.rs b/src/test/ui/consts/promote_fn_calls_std.rs
index bdb472f3a9cce..2e46e92362a80 100644
--- a/src/test/ui/consts/promote_fn_calls_std.rs
+++ b/src/test/ui/consts/promote_fn_calls_std.rs
@@ -1,28 +1,28 @@
 // build-pass (FIXME(62277): could be check-pass?)
 
 fn main() {
-    let x: &'static u8 = &u8::max_value();
-    let x: &'static u16 = &u16::max_value();
-    let x: &'static u32 = &u32::max_value();
-    let x: &'static u64 = &u64::max_value();
-    let x: &'static u128 = &u128::max_value();
-    let x: &'static usize = &usize::max_value();
-    let x: &'static u8 = &u8::min_value();
-    let x: &'static u16 = &u16::min_value();
-    let x: &'static u32 = &u32::min_value();
-    let x: &'static u64 = &u64::min_value();
-    let x: &'static u128 = &u128::min_value();
-    let x: &'static usize = &usize::min_value();
-    let x: &'static i8 = &i8::max_value();
-    let x: &'static i16 = &i16::max_value();
-    let x: &'static i32 = &i32::max_value();
-    let x: &'static i64 = &i64::max_value();
-    let x: &'static i128 = &i128::max_value();
-    let x: &'static isize = &isize::max_value();
-    let x: &'static i8 = &i8::min_value();
-    let x: &'static i16 = &i16::min_value();
-    let x: &'static i32 = &i32::min_value();
-    let x: &'static i64 = &i64::min_value();
-    let x: &'static i128 = &i128::min_value();
-    let x: &'static isize = &isize::min_value();
+    let x: &'static u8 = &u8::MAX;
+    let x: &'static u16 = &u16::MAX;
+    let x: &'static u32 = &u32::MAX;
+    let x: &'static u64 = &u64::MAX;
+    let x: &'static u128 = &u128::MAX;
+    let x: &'static usize = &usize::MAX;
+    let x: &'static u8 = &u8::MIN;
+    let x: &'static u16 = &u16::MIN;
+    let x: &'static u32 = &u32::MIN;
+    let x: &'static u64 = &u64::MIN;
+    let x: &'static u128 = &u128::MIN;
+    let x: &'static usize = &usize::MIN;
+    let x: &'static i8 = &i8::MAX;
+    let x: &'static i16 = &i16::MAX;
+    let x: &'static i32 = &i32::MAX;
+    let x: &'static i64 = &i64::MAX;
+    let x: &'static i128 = &i128::MAX;
+    let x: &'static isize = &isize::MAX;
+    let x: &'static i8 = &i8::MIN;
+    let x: &'static i16 = &i16::MIN;
+    let x: &'static i32 = &i32::MIN;
+    let x: &'static i64 = &i64::MIN;
+    let x: &'static i128 = &i128::MIN;
+    let x: &'static isize = &isize::MIN;
 }
diff --git a/src/test/ui/issues/issue-8460.rs b/src/test/ui/issues/issue-8460.rs
index 3fd576a8d3580..a7de4bd74aae4 100644
--- a/src/test/ui/issues/issue-8460.rs
+++ b/src/test/ui/issues/issue-8460.rs
@@ -27,21 +27,21 @@ macro_rules! check {
 
 fn main() {
     check![
-        isize::min_value() / -isize::one(),
-        i8::min_value() / -i8::one(),
-        i16::min_value() / -i16::one(),
-        i32::min_value() / -i32::one(),
-        i64::min_value() / -i64::one(),
+        isize::MIN / -isize::one(),
+        i8::MIN / -i8::one(),
+        i16::MIN / -i16::one(),
+        i32::MIN / -i32::one(),
+        i64::MIN / -i64::one(),
         1isize / isize::zero(),
         1i8 / i8::zero(),
         1i16 / i16::zero(),
         1i32 / i32::zero(),
         1i64 / i64::zero(),
-        isize::min_value() % -isize::one(),
-        i8::min_value() % -i8::one(),
-        i16::min_value() % -i16::one(),
-        i32::min_value() % -i32::one(),
-        i64::min_value() % -i64::one(),
+        isize::MIN % -isize::one(),
+        i8::MIN % -i8::one(),
+        i16::MIN % -i16::one(),
+        i32::MIN % -i32::one(),
+        i64::MIN % -i64::one(),
         1isize % isize::zero(),
         1i8 % i8::zero(),
         1i16 % i16::zero(),
diff --git a/src/test/ui/iterators/iter-step-overflow-debug.rs b/src/test/ui/iterators/iter-step-overflow-debug.rs
index 5d67c7cbb4256..67605d2fcc253 100644
--- a/src/test/ui/iterators/iter-step-overflow-debug.rs
+++ b/src/test/ui/iterators/iter-step-overflow-debug.rs
@@ -6,14 +6,14 @@ use std::panic;
 
 fn main() {
     let r = panic::catch_unwind(|| {
-        let mut it = u8::max_value()..;
+        let mut it = u8::MAX..;
         it.next().unwrap(); // 255
         it.next().unwrap();
     });
     assert!(r.is_err());
 
     let r = panic::catch_unwind(|| {
-        let mut it = i8::max_value()..;
+        let mut it = i8::MAX..;
         it.next().unwrap(); // 127
         it.next().unwrap();
     });
diff --git a/src/test/ui/iterators/iter-step-overflow-ndebug.rs b/src/test/ui/iterators/iter-step-overflow-ndebug.rs
index a0ad92071b66c..33e708769badb 100644
--- a/src/test/ui/iterators/iter-step-overflow-ndebug.rs
+++ b/src/test/ui/iterators/iter-step-overflow-ndebug.rs
@@ -2,11 +2,11 @@
 // compile-flags: -C debug_assertions=no
 
 fn main() {
-    let mut it = u8::max_value()..;
+    let mut it = u8::MAX..;
     assert_eq!(it.next().unwrap(), 255);
-    assert_eq!(it.next().unwrap(), u8::min_value());
+    assert_eq!(it.next().unwrap(), u8::MIN);
 
-    let mut it = i8::max_value()..;
+    let mut it = i8::MAX..;
     assert_eq!(it.next().unwrap(), 127);
-    assert_eq!(it.next().unwrap(), i8::min_value());
+    assert_eq!(it.next().unwrap(), i8::MIN);
 }
diff --git a/src/test/ui/iterators/iter-sum-overflow-debug.rs b/src/test/ui/iterators/iter-sum-overflow-debug.rs
index ee4ab4d24c6ab..b7667d1bbf6d9 100644
--- a/src/test/ui/iterators/iter-sum-overflow-debug.rs
+++ b/src/test/ui/iterators/iter-sum-overflow-debug.rs
@@ -6,22 +6,22 @@ use std::panic;
 
 fn main() {
     let r = panic::catch_unwind(|| {
-        [1, i32::max_value()].iter().sum::<i32>();
+        [1, i32::MAX].iter().sum::<i32>();
     });
     assert!(r.is_err());
 
     let r = panic::catch_unwind(|| {
-        [2, i32::max_value()].iter().product::<i32>();
+        [2, i32::MAX].iter().product::<i32>();
     });
     assert!(r.is_err());
 
     let r = panic::catch_unwind(|| {
-        [1, i32::max_value()].iter().cloned().sum::<i32>();
+        [1, i32::MAX].iter().cloned().sum::<i32>();
     });
     assert!(r.is_err());
 
     let r = panic::catch_unwind(|| {
-        [2, i32::max_value()].iter().cloned().product::<i32>();
+        [2, i32::MAX].iter().cloned().product::<i32>();
     });
     assert!(r.is_err());
 }
diff --git a/src/test/ui/iterators/iter-sum-overflow-ndebug.rs b/src/test/ui/iterators/iter-sum-overflow-ndebug.rs
index 61d63d41fb87e..69f4744cc2a1a 100644
--- a/src/test/ui/iterators/iter-sum-overflow-ndebug.rs
+++ b/src/test/ui/iterators/iter-sum-overflow-ndebug.rs
@@ -2,13 +2,13 @@
 // compile-flags: -C debug_assertions=no
 
 fn main() {
-    assert_eq!([1i32, i32::max_value()].iter().sum::<i32>(),
-               1i32.wrapping_add(i32::max_value()));
-    assert_eq!([2i32, i32::max_value()].iter().product::<i32>(),
-               2i32.wrapping_mul(i32::max_value()));
+    assert_eq!([1i32, i32::MAX].iter().sum::<i32>(),
+               1i32.wrapping_add(i32::MAX));
+    assert_eq!([2i32, i32::MAX].iter().product::<i32>(),
+               2i32.wrapping_mul(i32::MAX));
 
-    assert_eq!([1i32, i32::max_value()].iter().cloned().sum::<i32>(),
-               1i32.wrapping_add(i32::max_value()));
-    assert_eq!([2i32, i32::max_value()].iter().cloned().product::<i32>(),
-               2i32.wrapping_mul(i32::max_value()));
+    assert_eq!([1i32, i32::MAX].iter().cloned().sum::<i32>(),
+               1i32.wrapping_add(i32::MAX));
+    assert_eq!([2i32, i32::MAX].iter().cloned().product::<i32>(),
+               2i32.wrapping_mul(i32::MAX));
 }
diff --git a/src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs b/src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs
index 429f8e0bc9648..04ca7f8a31534 100644
--- a/src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs
+++ b/src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs
@@ -6,22 +6,22 @@ use std::panic;
 
 fn main() {
     let r = panic::catch_unwind(|| {
-        [1, i32::max_value()].iter().sum::<i32>();
+        [1, i32::MAX].iter().sum::<i32>();
     });
     assert!(r.is_err());
 
     let r = panic::catch_unwind(|| {
-        [2, i32::max_value()].iter().product::<i32>();
+        [2, i32::MAX].iter().product::<i32>();
     });
     assert!(r.is_err());
 
     let r = panic::catch_unwind(|| {
-        [1, i32::max_value()].iter().cloned().sum::<i32>();
+        [1, i32::MAX].iter().cloned().sum::<i32>();
     });
     assert!(r.is_err());
 
     let r = panic::catch_unwind(|| {
-        [2, i32::max_value()].iter().cloned().product::<i32>();
+        [2, i32::MAX].iter().cloned().product::<i32>();
     });
     assert!(r.is_err());
 }
diff --git a/src/test/ui/numbers-arithmetic/i128.rs b/src/test/ui/numbers-arithmetic/i128.rs
index ef558c0aa0c02..d61a1ab03b6b3 100644
--- a/src/test/ui/numbers-arithmetic/i128.rs
+++ b/src/test/ui/numbers-arithmetic/i128.rs
@@ -87,7 +87,7 @@ fn main() {
     assert_eq!((-z).checked_mul(-z), Some(0x734C_C2F2_A521));
     assert_eq!((z).checked_mul(z), Some(0x734C_C2F2_A521));
     assert_eq!((k).checked_mul(k), None);
-    let l: i128 = b(i128::min_value());
+    let l: i128 = b(i128::MIN);
     let o: i128 = b(17);
     assert_eq!(l.checked_sub(b(2)), None);
     assert_eq!(l.checked_add(l), None);
diff --git a/src/test/ui/numbers-arithmetic/int-abs-overflow.rs b/src/test/ui/numbers-arithmetic/int-abs-overflow.rs
index 2bc018445db9e..10ec3f0c6624e 100644
--- a/src/test/ui/numbers-arithmetic/int-abs-overflow.rs
+++ b/src/test/ui/numbers-arithmetic/int-abs-overflow.rs
@@ -5,9 +5,9 @@
 use std::thread;
 
 fn main() {
-    assert!(thread::spawn(|| i8::min_value().abs()).join().is_err());
-    assert!(thread::spawn(|| i16::min_value().abs()).join().is_err());
-    assert!(thread::spawn(|| i32::min_value().abs()).join().is_err());
-    assert!(thread::spawn(|| i64::min_value().abs()).join().is_err());
-    assert!(thread::spawn(|| isize::min_value().abs()).join().is_err());
+    assert!(thread::spawn(|| i8::MIN.abs()).join().is_err());
+    assert!(thread::spawn(|| i16::MIN.abs()).join().is_err());
+    assert!(thread::spawn(|| i32::MIN.abs()).join().is_err());
+    assert!(thread::spawn(|| i64::MIN.abs()).join().is_err());
+    assert!(thread::spawn(|| isize::MIN.abs()).join().is_err());
 }
diff --git a/src/test/ui/numbers-arithmetic/promoted_overflow_opt.rs b/src/test/ui/numbers-arithmetic/promoted_overflow_opt.rs
index a3b8ff58a7359..4785abbc55470 100644
--- a/src/test/ui/numbers-arithmetic/promoted_overflow_opt.rs
+++ b/src/test/ui/numbers-arithmetic/promoted_overflow_opt.rs
@@ -5,5 +5,5 @@
 
 fn main() {
     let x = &(0u32 - 1);
-    assert_eq!(*x, u32::max_value())
+    assert_eq!(*x, u32::MAX)
 }
diff --git a/src/test/ui/numbers-arithmetic/u128.rs b/src/test/ui/numbers-arithmetic/u128.rs
index 0b2305c6e8b1a..d7e28055b2154 100644
--- a/src/test/ui/numbers-arithmetic/u128.rs
+++ b/src/test/ui/numbers-arithmetic/u128.rs
@@ -53,14 +53,14 @@ fn main() {
     assert_eq!("10000000000000000000000000000000000000000000000000000000000000000000",
                format!("{:b}", j));
     assert_eq!("340282366920938463463374607431768211455",
-        format!("{}", u128::max_value()));
+        format!("{}", u128::MAX));
     assert_eq!("147573952589676412928", format!("{:?}", j));
     // common traits
     assert_eq!(x, b(x.clone()));
     // overflow checks
     assert_eq!((z).checked_mul(z), Some(0x734C_C2F2_A521));
     assert_eq!((k).checked_mul(k), None);
-    let l: u128 = b(u128::max_value() - 10);
+    let l: u128 = b(u128::MAX - 10);
     let o: u128 = b(17);
     assert_eq!(l.checked_add(b(11)), None);
     assert_eq!(l.checked_sub(l), Some(0));
diff --git a/src/test/ui/simd/simd-intrinsic-generic-arithmetic-saturating.rs b/src/test/ui/simd/simd-intrinsic-generic-arithmetic-saturating.rs
index b2ddcf023ebcb..844d592bd8733 100644
--- a/src/test/ui/simd/simd-intrinsic-generic-arithmetic-saturating.rs
+++ b/src/test/ui/simd/simd-intrinsic-generic-arithmetic-saturating.rs
@@ -21,7 +21,7 @@ extern "platform-intrinsic" {
 fn main() {
     // unsigned
     {
-        const M: u32 = u32::max_value();
+        const M: u32 = u32::MAX;
 
         let a = u32x4(1, 2, 3, 4);
         let b = u32x4(2, 4, 6, 8);
@@ -49,8 +49,8 @@ fn main() {
 
     // signed
     {
-        const MIN: i32 = i32::min_value();
-        const MAX: i32 = i32::max_value();
+        const MIN: i32 = i32::MIN;
+        const MAX: i32 = i32::MAX;
 
         let a = i32x4(1, 2, 3, 4);
         let b = i32x4(2, 4, 6, 8);
diff --git a/src/test/ui/simd/simd-intrinsic-generic-bitmask.rs b/src/test/ui/simd/simd-intrinsic-generic-bitmask.rs
index b28f742a92e94..a323bd9e82b4a 100644
--- a/src/test/ui/simd/simd-intrinsic-generic-bitmask.rs
+++ b/src/test/ui/simd/simd-intrinsic-generic-bitmask.rs
@@ -39,7 +39,7 @@ fn main() {
     let e = 0b_1101;
 
     // Check usize / isize
-    let msize: Tx4<usize> = Tx4(usize::max_value(), 0, usize::max_value(), usize::max_value());
+    let msize: Tx4<usize> = Tx4(usize::MAX, 0, usize::MAX, usize::MAX);
 
     unsafe {
         let r: u8 = simd_bitmask(z);
diff --git a/src/test/ui/simd/simd-intrinsic-generic-reduction.rs b/src/test/ui/simd/simd-intrinsic-generic-reduction.rs
index 4195444a73f67..8b5afeac0bc2d 100644
--- a/src/test/ui/simd/simd-intrinsic-generic-reduction.rs
+++ b/src/test/ui/simd/simd-intrinsic-generic-reduction.rs
@@ -100,7 +100,7 @@ fn main() {
         let r: u32 = simd_reduce_max(x);
         assert_eq!(r, 4_u32);
 
-        let t = u32::max_value();
+        let t = u32::MAX;
         let x = u32x4(t, t, t, t);
         let r: u32 = simd_reduce_and(x);
         assert_eq!(r, t);

From 7bb3a45dde8c43f28a326f7304c479a150598129 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= <faern@faern.net>
Date: Tue, 17 Dec 2019 19:36:23 +0100
Subject: [PATCH 07/15] Remove usage of module level MAX/MIN constants

---
 src/etc/test-float-parse/u64-pow2.rs          |  1 -
 src/liballoc/alloc.rs                         |  1 -
 src/liballoc/collections/binary_heap.rs       |  1 -
 src/liballoc/raw_vec.rs                       |  4 +-
 src/liballoc/rc.rs                            |  1 -
 src/liballoc/slice.rs                         |  1 -
 src/liballoc/sync.rs                          |  1 -
 src/liballoc/tests.rs                         |  1 -
 src/liballoc/tests/btree/map.rs               |  2 +-
 src/liballoc/tests/string.rs                  |  1 -
 src/liballoc/tests/vec_deque.rs               |  1 -
 src/libcore/alloc.rs                          |  1 -
 src/libcore/iter/adapters/chain.rs            |  1 -
 src/libcore/iter/adapters/mod.rs              |  1 -
 src/libcore/iter/range.rs                     |  1 -
 src/libcore/iter/sources.rs                   |  1 -
 src/libcore/num/flt2dec/mod.rs                |  1 -
 src/libcore/ptr/const_ptr.rs                  |  4 +-
 src/libcore/slice/memchr.rs                   |  2 +-
 src/libcore/slice/mod.rs                      |  1 -
 src/libcore/str/pattern.rs                    |  1 -
 src/libcore/tests/iter.rs                     | 49 ++++++++-----------
 src/libcore/tests/num/int_macros.rs           |  1 -
 src/libcore/time.rs                           |  2 +-
 src/librustc/dep_graph/graph.rs               |  2 +-
 src/librustc/infer/type_variable.rs           |  1 -
 src/librustc/mir/mod.rs                       |  2 +-
 src/librustc/traits/object_safety.rs          |  2 +-
 src/librustc/traits/select.rs                 |  8 +--
 src/librustc/ty/layout.rs                     |  1 -
 src/librustc/ty/query/on_disk_cache.rs        |  2 +-
 src/librustc_codegen_llvm/intrinsic.rs        |  2 +-
 src/librustc_codegen_ssa/back/write.rs        |  2 +-
 src/librustc_codegen_ssa/base.rs              |  2 +-
 src/librustc_codegen_ssa/mir/rvalue.rs        |  2 -
 .../graph/implementation/mod.rs               |  1 -
 src/librustc_data_structures/profiling.rs     |  1 -
 src/librustc_errors/emitter.rs                | 10 ++--
 src/librustc_hir/def_id.rs                    |  1 -
 src/librustc_index/bit_set.rs                 |  2 +-
 src/librustc_index/vec.rs                     |  1 -
 src/librustc_lint/types.rs                    |  2 +-
 src/librustc_metadata/rmeta/decoder.rs        |  1 -
 src/librustc_metadata/rmeta/encoder.rs        |  1 -
 src/librustc_mir/build/matches/util.rs        |  1 -
 src/librustc_mir/build/mod.rs                 |  1 -
 src/librustc_mir/dataflow/mod.rs              |  1 -
 src/librustc_mir/hair/pattern/_match.rs       |  1 -
 src/librustc_mir/transform/promote_consts.rs  |  2 +-
 src/librustc_passes/liveness.rs               |  2 +-
 src/librustc_resolve/late.rs                  |  6 +--
 src/librustc_span/lib.rs                      |  2 +-
 src/librustc_typeck/collect.rs                |  4 +-
 src/librustdoc/clean/mod.rs                   |  1 -
 src/librustdoc/passes/unindent_comments.rs    |  1 -
 src/libserialize/tests/json.rs                |  2 +-
 src/libserialize/tests/opaque.rs              | 20 ++++----
 src/libstd/collections/hash/map.rs            |  2 +-
 src/libstd/lib.rs                             | 26 +++++++++-
 src/libstd/sync/mpsc/shared.rs                |  1 -
 src/libstd/sync/mpsc/stream.rs                |  1 -
 src/libstd/sync/mpsc/sync.rs                  |  1 -
 src/libstd/sys/hermit/thread.rs               |  1 -
 src/libstd/sys/unix/process/zircon.rs         |  1 -
 src/libstd/thread/mod.rs                      |  2 +-
 src/libsyntax/attr/mod.rs                     |  2 +-
 src/libsyntax/util/comments.rs                |  2 -
 src/test/codegen/issue-56927.rs               |  1 -
 src/test/compile-fail/consts/issue-55878.rs   |  2 +-
 src/test/run-fail/bounds-check-no-overflow.rs |  1 -
 .../run-fail/hashmap-capacity-overflow.rs     |  1 -
 src/test/run-fail/overflowing-neg.rs          |  2 +-
 src/test/ui/consts/const-err-early.rs         |  2 +-
 src/test/ui/consts/const-err-early.stderr     |  2 +-
 src/test/ui/consts/const-err-multi.rs         |  2 +-
 src/test/ui/consts/const-err-multi.stderr     |  2 +-
 src/test/ui/consts/const-err2.rs              |  2 +-
 src/test/ui/consts/const-err2.stderr          |  2 +-
 src/test/ui/consts/const-err3.rs              |  2 +-
 src/test/ui/consts/const-err3.stderr          |  2 +-
 .../const-eval/const-eval-overflow-2.rs       |  2 -
 .../const-eval/const-eval-overflow-3.rs       |  2 -
 .../const-eval/const-eval-overflow-3b.rs      |  2 -
 .../const-eval/const-eval-overflow-4.rs       |  2 -
 .../const-eval/const-eval-overflow-4b.rs      |  3 --
 .../consts/const-eval/const-eval-overflow2.rs |  2 -
 .../const-eval/const-eval-overflow2b.rs       |  2 -
 .../const-eval/const-eval-overflow2c.rs       |  2 -
 src/test/ui/consts/const-eval/dangling.rs     |  2 +-
 .../ui/consts/const-int-overflowing-rpass.rs  |  2 +-
 .../ui/consts/const-match-check.eval1.stderr  |  4 +-
 .../ui/consts/const-match-check.eval2.stderr  |  4 +-
 .../consts/const-match-check.matchck.stderr   | 16 +++---
 src/test/ui/consts/const-negation.rs          | 10 ++--
 .../ui/consts/const-pattern-irrefutable.rs    |  6 +--
 .../consts/const-pattern-irrefutable.stderr   |  6 +--
 src/test/ui/consts/promotion.rs               |  2 +-
 src/test/ui/discrim/discrim-ill-typed.rs      |  2 -
 src/test/ui/discrim/discrim-overflow-2.rs     |  2 -
 src/test/ui/discrim/discrim-overflow.rs       |  2 -
 src/test/ui/drop/dynamic-drop-async.rs        |  1 -
 src/test/ui/drop/dynamic-drop.rs              |  1 -
 ...ture-gate-precise_pointer_size_matching.rs |  4 +-
 ...oop-refutable-pattern-error-message.stderr |  4 +-
 src/test/ui/ifmt.rs                           |  1 -
 src/test/ui/issues/issue-22933-3.stderr       |  2 +-
 src/test/ui/issues/issue-23833.rs             |  2 -
 src/test/ui/issues/issue-37686.rs             |  2 +-
 src/test/ui/issues/issue-41880.rs             |  2 +-
 src/test/ui/issues/issue-48006.rs             |  4 +-
 src/test/ui/issues/issue-8460-const.rs        |  1 -
 src/test/ui/issues/issue-8460-const2.rs       |  1 -
 .../ui/iterators/iter-count-overflow-debug.rs |  5 +-
 .../iterators/iter-count-overflow-ndebug.rs   |  5 +-
 .../iterators/iter-position-overflow-debug.rs |  5 +-
 .../iter-position-overflow-ndebug.rs          |  5 +-
 src/test/ui/macros/macro-first-set.rs         |  2 +-
 ...type-move-out-of-closure-env-issue-1965.rs |  2 -
 .../next-power-of-two-overflow-debug.rs       |  4 +-
 .../saturating-float-casts.rs                 |  3 --
 .../ui/numbers-arithmetic/shift-near-oflo.rs  | 20 ++++----
 src/test/ui/numbers-arithmetic/u128-as-f32.rs |  1 -
 .../exhaustiveness-non-exhaustive.rs          |  6 +--
 .../exhaustiveness-non-exhaustive.stderr      | 12 ++---
 .../usefulness/exhaustive_integer_patterns.rs |  2 +-
 .../exhaustive_integer_patterns.stderr        | 28 +++++------
 .../match-byte-array-patterns-2.stderr        |  4 +-
 .../usefulness/match-non-exhaustive.stderr    |  4 +-
 .../usefulness/non-exhaustive-match.rs        |  4 +-
 .../usefulness/non-exhaustive-match.stderr    |  4 +-
 .../usefulness/refutable-pattern-errors.rs    |  2 +-
 .../refutable-pattern-errors.stderr           |  4 +-
 src/test/ui/precise_pointer_size_matching.rs  |  2 -
 .../ui/precise_pointer_size_matching.stderr   |  8 +--
 .../ui/regions/regions-addr-of-upvar-self.rs  |  2 -
 .../link-ordinal-too-large.stderr             |  2 +-
 src/test/ui/sleep.rs                          |  1 -
 .../structs-enums/discrim-explicit-23030.rs   |  2 -
 .../const-pat-non-exaustive-let-new-var.rs    |  2 +-
 ...const-pat-non-exaustive-let-new-var.stderr |  2 +-
 src/test/ui/wrapping-int-api.rs               |  3 --
 src/test/ui/wrapping-int-combinations.rs      | 24 ++++-----
 142 files changed, 210 insertions(+), 293 deletions(-)

diff --git a/src/etc/test-float-parse/u64-pow2.rs b/src/etc/test-float-parse/u64-pow2.rs
index 1c9bda948ffd3..7e67e2b1246ef 100644
--- a/src/etc/test-float-parse/u64-pow2.rs
+++ b/src/etc/test-float-parse/u64-pow2.rs
@@ -1,7 +1,6 @@
 mod _common;
 
 use _common::validate;
-use std::u64;
 
 fn main() {
     for exp in 19..64 {
diff --git a/src/liballoc/alloc.rs b/src/liballoc/alloc.rs
index 0c0dc928b95df..e0f6e0d1872a6 100644
--- a/src/liballoc/alloc.rs
+++ b/src/liballoc/alloc.rs
@@ -4,7 +4,6 @@
 
 use core::intrinsics::{min_align_of_val, size_of_val};
 use core::ptr::{NonNull, Unique};
-use core::usize;
 
 #[stable(feature = "alloc_module", since = "1.28.0")]
 #[doc(inline)]
diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs
index c527b378f7465..426aa536ec39e 100644
--- a/src/liballoc/collections/binary_heap.rs
+++ b/src/liballoc/collections/binary_heap.rs
@@ -20,7 +20,6 @@
 //! ```
 //! use std::cmp::Ordering;
 //! use std::collections::BinaryHeap;
-//! use std::usize;
 //!
 //! #[derive(Copy, Clone, Eq, PartialEq)]
 //! struct State {
diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs
index 86aed612efe04..afebe6b56dc10 100644
--- a/src/liballoc/raw_vec.rs
+++ b/src/liballoc/raw_vec.rs
@@ -52,7 +52,7 @@ impl<T, A: Alloc> RawVec<T, A> {
     /// Like `new`, but parameterized over the choice of allocator for
     /// the returned `RawVec`.
     pub const fn new_in(a: A) -> Self {
-        let cap = if mem::size_of::<T>() == 0 { core::usize::MAX } else { 0 };
+        let cap = if mem::size_of::<T>() == 0 { usize::MAX } else { 0 };
 
         // `Unique::empty()` doubles as "unallocated" and "zero-sized allocation".
         RawVec { ptr: Unique::empty(), cap, a }
@@ -732,7 +732,7 @@ unsafe impl<#[may_dangle] T, A: Alloc> Drop for RawVec<T, A> {
 
 #[inline]
 fn alloc_guard(alloc_size: usize) -> Result<(), TryReserveError> {
-    if mem::size_of::<usize>() < 8 && alloc_size > core::isize::MAX as usize {
+    if mem::size_of::<usize>() < 8 && alloc_size > isize::MAX as usize {
         Err(CapacityOverflow)
     } else {
         Ok(())
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs
index 2ea10cc3c306b..751c526eba064 100644
--- a/src/liballoc/rc.rs
+++ b/src/liballoc/rc.rs
@@ -250,7 +250,6 @@ use core::ops::{CoerceUnsized, Deref, DispatchFromDyn, Receiver};
 use core::pin::Pin;
 use core::ptr::{self, NonNull};
 use core::slice::{self, from_raw_parts_mut};
-use core::usize;
 
 use crate::alloc::{box_free, handle_alloc_error, Alloc, Global, Layout};
 use crate::string::String;
diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs
index 4e538a01ea86c..a65a99472ae69 100644
--- a/src/liballoc/slice.rs
+++ b/src/liballoc/slice.rs
@@ -90,7 +90,6 @@ use core::borrow::{Borrow, BorrowMut};
 use core::cmp::Ordering::{self, Less};
 use core::mem::{self, size_of};
 use core::ptr;
-use core::{u16, u32, u8};
 
 use crate::borrow::ToOwned;
 use crate::boxed::Box;
diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs
index dc53ad2840727..8e70fcbde4e39 100644
--- a/src/liballoc/sync.rs
+++ b/src/liballoc/sync.rs
@@ -23,7 +23,6 @@ use core::ptr::{self, NonNull};
 use core::slice::{self, from_raw_parts_mut};
 use core::sync::atomic;
 use core::sync::atomic::Ordering::{Acquire, Relaxed, Release, SeqCst};
-use core::{isize, usize};
 
 use crate::alloc::{box_free, handle_alloc_error, Alloc, Global, Layout};
 use crate::boxed::Box;
diff --git a/src/liballoc/tests.rs b/src/liballoc/tests.rs
index 1b6e0bb291c35..21ab5c003ec57 100644
--- a/src/liballoc/tests.rs
+++ b/src/liballoc/tests.rs
@@ -4,7 +4,6 @@ use core::any::Any;
 use core::clone::Clone;
 use core::convert::TryInto;
 use core::f64;
-use core::i64;
 use core::ops::Deref;
 use core::result::Result::{Err, Ok};
 
diff --git a/src/liballoc/tests/btree/map.rs b/src/liballoc/tests/btree/map.rs
index 35ce1354f52e0..b01f167987d03 100644
--- a/src/liballoc/tests/btree/map.rs
+++ b/src/liballoc/tests/btree/map.rs
@@ -347,7 +347,7 @@ fn test_range_inclusive() {
 
 #[test]
 fn test_range_inclusive_max_value() {
-    let max = std::usize::MAX;
+    let max = usize::MAX;
     let map: BTreeMap<_, _> = vec![(max, 0)].into_iter().collect();
 
     assert_eq!(map.range(max..=max).collect::<Vec<_>>(), &[(&max, &0)]);
diff --git a/src/liballoc/tests/string.rs b/src/liballoc/tests/string.rs
index dd44495845961..f470f5a341d80 100644
--- a/src/liballoc/tests/string.rs
+++ b/src/liballoc/tests/string.rs
@@ -1,7 +1,6 @@
 use std::borrow::Cow;
 use std::collections::TryReserveError::*;
 use std::mem::size_of;
-use std::{isize, usize};
 
 pub trait IntoCow<'a, B: ?Sized>
 where
diff --git a/src/liballoc/tests/vec_deque.rs b/src/liballoc/tests/vec_deque.rs
index 1ab3694a3ca61..76b85c8c06553 100644
--- a/src/liballoc/tests/vec_deque.rs
+++ b/src/liballoc/tests/vec_deque.rs
@@ -3,7 +3,6 @@ use std::collections::{vec_deque::Drain, VecDeque};
 use std::fmt::Debug;
 use std::mem::size_of;
 use std::panic::catch_unwind;
-use std::{isize, usize};
 
 use crate::hash;
 
diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs
index b2d4b1b5fb916..2ffa866b7f0a5 100644
--- a/src/libcore/alloc.rs
+++ b/src/libcore/alloc.rs
@@ -9,7 +9,6 @@ use crate::fmt;
 use crate::mem;
 use crate::num::NonZeroUsize;
 use crate::ptr::{self, NonNull};
-use crate::usize;
 
 /// Represents the combination of a starting address and
 /// a total capacity of the returned block.
diff --git a/src/libcore/iter/adapters/chain.rs b/src/libcore/iter/adapters/chain.rs
index 3611a1aadaddb..85a2545e51a38 100644
--- a/src/libcore/iter/adapters/chain.rs
+++ b/src/libcore/iter/adapters/chain.rs
@@ -1,5 +1,4 @@
 use crate::ops::Try;
-use crate::usize;
 
 use super::super::{DoubleEndedIterator, FusedIterator, Iterator, TrustedLen};
 
diff --git a/src/libcore/iter/adapters/mod.rs b/src/libcore/iter/adapters/mod.rs
index 6eb837ed0fed8..90a9949617197 100644
--- a/src/libcore/iter/adapters/mod.rs
+++ b/src/libcore/iter/adapters/mod.rs
@@ -2,7 +2,6 @@ use crate::cmp;
 use crate::fmt;
 use crate::intrinsics;
 use crate::ops::{Add, AddAssign, Try};
-use crate::usize;
 
 use super::{from_fn, LoopState};
 use super::{DoubleEndedIterator, ExactSizeIterator, FusedIterator, Iterator, TrustedLen};
diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs
index eac3c107d2283..b237b9f1f462e 100644
--- a/src/libcore/iter/range.rs
+++ b/src/libcore/iter/range.rs
@@ -1,7 +1,6 @@
 use crate::convert::TryFrom;
 use crate::mem;
 use crate::ops::{self, Add, Sub, Try};
-use crate::usize;
 
 use super::{FusedIterator, TrustedLen};
 
diff --git a/src/libcore/iter/sources.rs b/src/libcore/iter/sources.rs
index a65d47cc2c1f0..54530830cdf19 100644
--- a/src/libcore/iter/sources.rs
+++ b/src/libcore/iter/sources.rs
@@ -1,6 +1,5 @@
 use crate::fmt;
 use crate::marker;
-use crate::usize;
 
 use super::{FusedIterator, TrustedLen};
 
diff --git a/src/libcore/num/flt2dec/mod.rs b/src/libcore/num/flt2dec/mod.rs
index 9e760c13c0cf0..f76e9d608257e 100644
--- a/src/libcore/num/flt2dec/mod.rs
+++ b/src/libcore/num/flt2dec/mod.rs
@@ -123,7 +123,6 @@ functions.
 )]
 
 pub use self::decoder::{decode, DecodableFloat, Decoded, FullDecoded};
-use crate::i16;
 
 pub mod decoder;
 pub mod estimator;
diff --git a/src/libcore/ptr/const_ptr.rs b/src/libcore/ptr/const_ptr.rs
index fc3c02e1f066d..cea8f62248f6c 100644
--- a/src/libcore/ptr/const_ptr.rs
+++ b/src/libcore/ptr/const_ptr.rs
@@ -288,7 +288,7 @@ impl<T: ?Sized> *const T {
         T: Sized,
     {
         let pointee_size = mem::size_of::<T>();
-        assert!(0 < pointee_size && pointee_size <= isize::max_value() as usize);
+        assert!(0 < pointee_size && pointee_size <= isize::MAX as usize);
         intrinsics::ptr_offset_from(self, origin)
     }
 
@@ -333,7 +333,7 @@ impl<T: ?Sized> *const T {
         T: Sized,
     {
         let pointee_size = mem::size_of::<T>();
-        assert!(0 < pointee_size && pointee_size <= isize::max_value() as usize);
+        assert!(0 < pointee_size && pointee_size <= isize::MAX as usize);
 
         let d = isize::wrapping_sub(self as _, origin as _);
         d.wrapping_div(pointee_size as _)
diff --git a/src/libcore/slice/memchr.rs b/src/libcore/slice/memchr.rs
index 2a2169dd348c2..3b13ed5fed396 100644
--- a/src/libcore/slice/memchr.rs
+++ b/src/libcore/slice/memchr.rs
@@ -34,7 +34,7 @@ fn repeat_byte(b: u8) -> usize {
 #[cfg(not(target_pointer_width = "16"))]
 #[inline]
 fn repeat_byte(b: u8) -> usize {
-    (b as usize) * (crate::usize::MAX / 255)
+    (b as usize) * (usize::MAX / 255)
 }
 
 /// Returns the first index matching the byte `x` in `text`.
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs
index d3c643bed0a45..c47ea20bebc0b 100644
--- a/src/libcore/slice/mod.rs
+++ b/src/libcore/slice/mod.rs
@@ -27,7 +27,6 @@ use crate::cmp;
 use crate::cmp::Ordering::{self, Equal, Greater, Less};
 use crate::fmt;
 use crate::intrinsics::{assume, exact_div, is_aligned_and_not_null, unchecked_sub};
-use crate::isize;
 use crate::iter::*;
 use crate::marker::{self, Copy, Send, Sized, Sync};
 use crate::mem;
diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs
index 2cbdeb2e4eed8..40c54ab89d284 100644
--- a/src/libcore/str/pattern.rs
+++ b/src/libcore/str/pattern.rs
@@ -14,7 +14,6 @@
 use crate::cmp;
 use crate::fmt;
 use crate::slice::memchr;
-use crate::usize;
 
 // Pattern
 
diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs
index 8b8dc941534ee..815d06baf96c6 100644
--- a/src/libcore/tests/iter.rs
+++ b/src/libcore/tests/iter.rs
@@ -1,8 +1,6 @@
 use core::cell::Cell;
 use core::convert::TryFrom;
 use core::iter::*;
-use core::usize;
-use core::{i16, i8, isize};
 
 #[test]
 fn test_lt() {
@@ -2231,62 +2229,57 @@ fn test_range_inclusive_folds() {
 
 #[test]
 fn test_range_size_hint() {
-    use core::usize::MAX as UMAX;
     assert_eq!((0..0usize).size_hint(), (0, Some(0)));
     assert_eq!((0..100usize).size_hint(), (100, Some(100)));
-    assert_eq!((0..UMAX).size_hint(), (UMAX, Some(UMAX)));
+    assert_eq!((0..usize::MAX).size_hint(), (usize::MAX, Some(usize::MAX)));
 
-    let umax = u128::try_from(UMAX).unwrap();
+    let umax = u128::try_from(usize::MAX).unwrap();
     assert_eq!((0..0u128).size_hint(), (0, Some(0)));
     assert_eq!((0..100u128).size_hint(), (100, Some(100)));
-    assert_eq!((0..umax).size_hint(), (UMAX, Some(UMAX)));
-    assert_eq!((0..umax + 1).size_hint(), (UMAX, None));
+    assert_eq!((0..umax).size_hint(), (usize::MAX, Some(usize::MAX)));
+    assert_eq!((0..umax + 1).size_hint(), (usize::MAX, None));
 
-    use core::isize::{MAX as IMAX, MIN as IMIN};
     assert_eq!((0..0isize).size_hint(), (0, Some(0)));
     assert_eq!((-100..100isize).size_hint(), (200, Some(200)));
-    assert_eq!((IMIN..IMAX).size_hint(), (UMAX, Some(UMAX)));
+    assert_eq!((isize::MIN..isize::MAX).size_hint(), (usize::MAX, Some(usize::MAX)));
 
-    let imin = i128::try_from(IMIN).unwrap();
-    let imax = i128::try_from(IMAX).unwrap();
+    let imin = i128::try_from(isize::MIN).unwrap();
+    let imax = i128::try_from(isize::MAX).unwrap();
     assert_eq!((0..0i128).size_hint(), (0, Some(0)));
     assert_eq!((-100..100i128).size_hint(), (200, Some(200)));
-    assert_eq!((imin..imax).size_hint(), (UMAX, Some(UMAX)));
-    assert_eq!((imin..imax + 1).size_hint(), (UMAX, None));
+    assert_eq!((imin..imax).size_hint(), (usize::MAX, Some(usize::MAX)));
+    assert_eq!((imin..imax + 1).size_hint(), (usize::MAX, None));
 }
 
 #[test]
 fn test_range_inclusive_size_hint() {
-    use core::usize::MAX as UMAX;
     assert_eq!((1..=0usize).size_hint(), (0, Some(0)));
     assert_eq!((0..=0usize).size_hint(), (1, Some(1)));
     assert_eq!((0..=100usize).size_hint(), (101, Some(101)));
-    assert_eq!((0..=UMAX - 1).size_hint(), (UMAX, Some(UMAX)));
-    assert_eq!((0..=UMAX).size_hint(), (UMAX, None));
+    assert_eq!((0..=usize::MAX - 1).size_hint(), (usize::MAX, Some(usize::MAX)));
+    assert_eq!((0..=usize::MAX).size_hint(), (usize::MAX, None));
 
-    let umax = u128::try_from(UMAX).unwrap();
     assert_eq!((1..=0u128).size_hint(), (0, Some(0)));
     assert_eq!((0..=0u128).size_hint(), (1, Some(1)));
     assert_eq!((0..=100u128).size_hint(), (101, Some(101)));
-    assert_eq!((0..=umax - 1).size_hint(), (UMAX, Some(UMAX)));
-    assert_eq!((0..=umax).size_hint(), (UMAX, None));
-    assert_eq!((0..=umax + 1).size_hint(), (UMAX, None));
+    assert_eq!((0..=umax - 1).size_hint(), (usize::MAX, Some(usize::MAX)));
+    assert_eq!((0..=umax).size_hint(), (usize::MAX, None));
+    assert_eq!((0..=umax + 1).size_hint(), (usize::MAX, None));
 
-    use core::isize::{MAX as IMAX, MIN as IMIN};
     assert_eq!((0..=-1isize).size_hint(), (0, Some(0)));
     assert_eq!((0..=0isize).size_hint(), (1, Some(1)));
     assert_eq!((-100..=100isize).size_hint(), (201, Some(201)));
-    assert_eq!((IMIN..=IMAX - 1).size_hint(), (UMAX, Some(UMAX)));
-    assert_eq!((IMIN..=IMAX).size_hint(), (UMAX, None));
+    assert_eq!((isize::MIN..=isize::MAX - 1).size_hint(), (usize::MAX, Some(usize::MAX)));
+    assert_eq!((isize::MIN..=isize::MAX).size_hint(), (usize::MAX, None));
 
-    let imin = i128::try_from(IMIN).unwrap();
-    let imax = i128::try_from(IMAX).unwrap();
+    let imin = i128::try_from(isize::MIN).unwrap();
+    let imax = i128::try_from(isize::MAX).unwrap();
     assert_eq!((0..=-1i128).size_hint(), (0, Some(0)));
     assert_eq!((0..=0i128).size_hint(), (1, Some(1)));
     assert_eq!((-100..=100i128).size_hint(), (201, Some(201)));
-    assert_eq!((imin..=imax - 1).size_hint(), (UMAX, Some(UMAX)));
-    assert_eq!((imin..=imax).size_hint(), (UMAX, None));
-    assert_eq!((imin..=imax + 1).size_hint(), (UMAX, None));
+    assert_eq!((imin..=imax - 1).size_hint(), (usize::MAX, Some(usize::MAX)));
+    assert_eq!((imin..=imax).size_hint(), (usize::MAX, None));
+    assert_eq!((imin..=imax + 1).size_hint(), (usize::MAX, None));
 }
 
 #[test]
diff --git a/src/libcore/tests/num/int_macros.rs b/src/libcore/tests/num/int_macros.rs
index 4a44b5f24b910..bfd12f05a63e8 100644
--- a/src/libcore/tests/num/int_macros.rs
+++ b/src/libcore/tests/num/int_macros.rs
@@ -2,7 +2,6 @@ macro_rules! int_module {
     ($T:ident, $T_i:ident) => {
         #[cfg(test)]
         mod tests {
-            use core::isize;
             use core::mem;
             use core::ops::{BitAnd, BitOr, BitXor, Not, Shl, Shr};
             use core::$T_i::*;
diff --git a/src/libcore/time.rs b/src/libcore/time.rs
index 2ece2150e6bed..724cb0d8c1dab 100644
--- a/src/libcore/time.rs
+++ b/src/libcore/time.rs
@@ -12,9 +12,9 @@
 //! assert_eq!(Duration::new(5, 0), Duration::from_secs(5));
 //! ```
 
+use crate::fmt;
 use crate::iter::Sum;
 use crate::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
-use crate::{fmt, u64};
 
 const NANOS_PER_SEC: u32 = 1_000_000_000;
 const NANOS_PER_MILLI: u32 = 1_000_000;
diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs
index 0d03c834e0f7b..e9084d9b05c30 100644
--- a/src/librustc/dep_graph/graph.rs
+++ b/src/librustc/dep_graph/graph.rs
@@ -508,7 +508,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/infer/type_variable.rs b/src/librustc/infer/type_variable.rs
index 27bcb63fe15fe..59a894e43d1b0 100644
--- a/src/librustc/infer/type_variable.rs
+++ b/src/librustc/infer/type_variable.rs
@@ -8,7 +8,6 @@ use rustc_data_structures::unify as ut;
 use std::cmp;
 use std::marker::PhantomData;
 use std::ops::Range;
-use std::u32;
 
 pub struct TypeVariableTable<'tcx> {
     values: sv::SnapshotVec<Delegate>,
diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs
index a293fd128bdb0..841ff4474f5c6 100644
--- a/src/librustc/mir/mod.rs
+++ b/src/librustc/mir/mod.rs
@@ -34,7 +34,7 @@ use std::borrow::Cow;
 use std::fmt::{self, Debug, Display, Formatter, Write};
 use std::ops::Index;
 use std::slice;
-use std::{iter, mem, option, u32};
+use std::{iter, mem, option};
 pub use syntax::ast::Mutability;
 use syntax::ast::Name;
 
diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs
index 30ffdc23d9893..398f00aa22986 100644
--- a/src/librustc/traits/object_safety.rs
+++ b/src/librustc/traits/object_safety.rs
@@ -564,7 +564,7 @@ impl<'tcx> TyCtxt<'tcx> {
         // FIXME(mikeyhew) this is a total hack. Once object_safe_for_dispatch is stabilized, we can
         // replace this with `dyn Trait`
         let unsized_self_ty: Ty<'tcx> =
-            self.mk_ty_param(::std::u32::MAX, Symbol::intern("RustaceansAreAwesome"));
+            self.mk_ty_param(u32::MAX, Symbol::intern("RustaceansAreAwesome"));
 
         // `Receiver[Self => U]`
         let unsized_receiver_ty =
diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs
index 0d35ad2a4cdda..92322036fec0a 100644
--- a/src/librustc/traits/select.rs
+++ b/src/librustc/traits/select.rs
@@ -3920,11 +3920,7 @@ struct ProvisionalEvaluation {
 
 impl<'tcx> Default for ProvisionalEvaluationCache<'tcx> {
     fn default() -> Self {
-        Self {
-            dfn: Cell::new(0),
-            reached_depth: Cell::new(std::usize::MAX),
-            map: Default::default(),
-        }
+        Self { dfn: Cell::new(0), reached_depth: Cell::new(usize::MAX), map: Default::default() }
     }
 }
 
@@ -4023,7 +4019,7 @@ impl<'tcx> ProvisionalEvaluationCache<'tcx> {
             op(fresh_trait_ref, eval.result);
         }
 
-        self.reached_depth.set(std::usize::MAX);
+        self.reached_depth.set(usize::MAX);
     }
 }
 
diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs
index ba07b8a44387a..3e4f6f4c3aa10 100644
--- a/src/librustc/ty/layout.rs
+++ b/src/librustc/ty/layout.rs
@@ -7,7 +7,6 @@ use syntax::attr;
 
 use std::cmp;
 use std::fmt;
-use std::i128;
 use std::iter;
 use std::mem;
 use std::ops::Bound;
diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs
index 6758aedfabc14..80e11538ca826 100644
--- a/src/librustc/ty/query/on_disk_cache.rs
+++ b/src/librustc/ty/query/on_disk_cache.rs
@@ -93,7 +93,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_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs
index 1c7146308389a..785cd0abac8cb 100644
--- a/src/librustc_codegen_llvm/intrinsic.rs
+++ b/src/librustc_codegen_llvm/intrinsic.rs
@@ -26,7 +26,7 @@ use rustc_codegen_ssa::traits::*;
 use rustc_span::Span;
 
 use std::cmp::Ordering;
-use std::{i128, iter, u128};
+use std::iter;
 
 fn get_simple_intrinsic(cx: &CodegenCx<'ll, '_>, name: &str) -> Option<&'ll Value> {
     let llvm_name = match name {
diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs
index 44ed297ea8396..e1d99ae3c1038 100644
--- a/src/librustc_codegen_ssa/back/write.rs
+++ b/src/librustc_codegen_ssa/back/write.rs
@@ -1516,7 +1516,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
     }
 }
 
-pub const CODEGEN_WORKER_ID: usize = ::std::usize::MAX;
+pub const CODEGEN_WORKER_ID: usize = usize::MAX;
 
 fn spawn_work<B: ExtraBackendMethods>(cgcx: CodegenContext<B>, work: WorkItem<B>) {
     thread::spawn(move || {
diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs
index 6750b7e65ba9e..2b6a57b7b6277 100644
--- a/src/librustc_codegen_ssa/base.rs
+++ b/src/librustc_codegen_ssa/base.rs
@@ -503,7 +503,7 @@ fn get_argc_argv<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
     }
 }
 
-pub const CODEGEN_WORKER_ID: usize = ::std::usize::MAX;
+pub const CODEGEN_WORKER_ID: usize = usize::MAX;
 
 pub fn codegen_crate<B: ExtraBackendMethods>(
     backend: B,
diff --git a/src/librustc_codegen_ssa/mir/rvalue.rs b/src/librustc_codegen_ssa/mir/rvalue.rs
index 39cb501b7aa98..d90d3ad303132 100644
--- a/src/librustc_codegen_ssa/mir/rvalue.rs
+++ b/src/librustc_codegen_ssa/mir/rvalue.rs
@@ -16,8 +16,6 @@ use rustc_apfloat::{ieee, Float, Round, Status};
 use rustc_span::source_map::{Span, DUMMY_SP};
 use rustc_span::symbol::sym;
 
-use std::{i128, u128};
-
 impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
     pub fn codegen_rvalue(
         &mut self,
diff --git a/src/librustc_data_structures/graph/implementation/mod.rs b/src/librustc_data_structures/graph/implementation/mod.rs
index f705c2f0b75f3..1aa7ac024d94e 100644
--- a/src/librustc_data_structures/graph/implementation/mod.rs
+++ b/src/librustc_data_structures/graph/implementation/mod.rs
@@ -23,7 +23,6 @@
 use crate::snapshot_vec::{SnapshotVec, SnapshotVecDelegate};
 use rustc_index::bit_set::BitSet;
 use std::fmt::Debug;
-use std::usize;
 
 #[cfg(test)]
 mod tests;
diff --git a/src/librustc_data_structures/profiling.rs b/src/librustc_data_structures/profiling.rs
index 840a2603deb79..5c0668daf3758 100644
--- a/src/librustc_data_structures/profiling.rs
+++ b/src/librustc_data_structures/profiling.rs
@@ -6,7 +6,6 @@ use std::process;
 use std::sync::Arc;
 use std::thread::ThreadId;
 use std::time::{Duration, Instant};
-use std::u32;
 
 use crate::cold_path;
 
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs
index 541b89e6fce5f..fb992ee488079 100644
--- a/src/librustc_errors/emitter.rs
+++ b/src/librustc_errors/emitter.rs
@@ -1303,7 +1303,7 @@ impl EmitterWriter {
                 let mut multilines = FxHashMap::default();
 
                 // Get the left-side margin to remove it
-                let mut whitespace_margin = std::usize::MAX;
+                let mut whitespace_margin = usize::MAX;
                 for line_idx in 0..annotated_file.lines.len() {
                     let file = annotated_file.file.clone();
                     let line = &annotated_file.lines[line_idx];
@@ -1315,19 +1315,19 @@ impl EmitterWriter {
                         }
                     }
                 }
-                if whitespace_margin == std::usize::MAX {
+                if whitespace_margin == usize::MAX {
                     whitespace_margin = 0;
                 }
 
                 // Left-most column any visible span points at.
-                let mut span_left_margin = std::usize::MAX;
+                let mut span_left_margin = usize::MAX;
                 for line in &annotated_file.lines {
                     for ann in &line.annotations {
                         span_left_margin = min(span_left_margin, ann.start_col);
                         span_left_margin = min(span_left_margin, ann.end_col);
                     }
                 }
-                if span_left_margin == std::usize::MAX {
+                if span_left_margin == usize::MAX {
                     span_left_margin = 0;
                 }
 
@@ -1363,7 +1363,7 @@ impl EmitterWriter {
                 } else {
                     term_size::dimensions()
                         .map(|(w, _)| w.saturating_sub(code_offset))
-                        .unwrap_or(std::usize::MAX)
+                        .unwrap_or(usize::MAX)
                 };
 
                 let margin = Margin::new(
diff --git a/src/librustc_hir/def_id.rs b/src/librustc_hir/def_id.rs
index f8cacdc6238e8..3f5ca891a3adc 100644
--- a/src/librustc_hir/def_id.rs
+++ b/src/librustc_hir/def_id.rs
@@ -1,7 +1,6 @@
 use rustc_data_structures::AtomicRef;
 use rustc_index::vec::Idx;
 use std::fmt;
-use std::u32;
 
 rustc_index::newtype_index! {
     pub struct CrateId {
diff --git a/src/librustc_index/bit_set.rs b/src/librustc_index/bit_set.rs
index 2a1a56076728e..46c38840516e2 100644
--- a/src/librustc_index/bit_set.rs
+++ b/src/librustc_index/bit_set.rs
@@ -307,7 +307,7 @@ impl<'a, T: Idx> BitIter<'a, T> {
         // additional state about whether we have started.
         BitIter {
             word: 0,
-            offset: std::usize::MAX - (WORD_BITS - 1),
+            offset: usize::MAX - (WORD_BITS - 1),
             iter: words.iter(),
             marker: PhantomData,
         }
diff --git a/src/librustc_index/vec.rs b/src/librustc_index/vec.rs
index 1f6a330cdc235..0b13a96d96bed 100644
--- a/src/librustc_index/vec.rs
+++ b/src/librustc_index/vec.rs
@@ -7,7 +7,6 @@ use std::iter::{self, FromIterator};
 use std::marker::PhantomData;
 use std::ops::{Index, IndexMut, Range, RangeBounds};
 use std::slice;
-use std::u32;
 use std::vec;
 
 /// Represents some newtyped `usize` wrapper.
diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs
index 6c3aee1dafef1..8b10bc4524a54 100644
--- a/src/librustc_lint/types.rs
+++ b/src/librustc_lint/types.rs
@@ -21,7 +21,7 @@ use syntax::{ast, attr};
 
 use log::debug;
 use std::cmp;
-use std::{f32, f64, i16, i32, i64, i8, u16, u32, u64, u8};
+use std::{f32, f64};
 
 declare_lint! {
     UNUSED_COMPARISONS,
diff --git a/src/librustc_metadata/rmeta/decoder.rs b/src/librustc_metadata/rmeta/decoder.rs
index 1ed6b748d873a..f92de6bd99bd7 100644
--- a/src/librustc_metadata/rmeta/decoder.rs
+++ b/src/librustc_metadata/rmeta/decoder.rs
@@ -30,7 +30,6 @@ use rustc_index::vec::{Idx, IndexVec};
 use std::io;
 use std::mem;
 use std::num::NonZeroUsize;
-use std::u32;
 
 use log::debug;
 use proc_macro::bridge::client::ProcMacro;
diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs
index fc7eae1e6c7a1..f7c1c008f7220 100644
--- a/src/librustc_metadata/rmeta/encoder.rs
+++ b/src/librustc_metadata/rmeta/encoder.rs
@@ -30,7 +30,6 @@ use rustc_span::{self, FileName, SourceFile, Span};
 use std::hash::Hash;
 use std::num::NonZeroUsize;
 use std::path::Path;
-use std::u32;
 use syntax::ast;
 use syntax::attr;
 use syntax::expand::is_proc_macro_attr;
diff --git a/src/librustc_mir/build/matches/util.rs b/src/librustc_mir/build/matches/util.rs
index b6e643a65105b..1bc05aaed2010 100644
--- a/src/librustc_mir/build/matches/util.rs
+++ b/src/librustc_mir/build/matches/util.rs
@@ -5,7 +5,6 @@ use rustc::mir::*;
 use rustc::ty;
 use smallvec::SmallVec;
 use std::convert::TryInto;
-use std::u32;
 
 impl<'a, 'tcx> Builder<'a, 'tcx> {
     pub fn field_match_pairs<'pat>(
diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs
index 39edcc981a005..13c6e35c01dc5 100644
--- a/src/librustc_mir/build/mod.rs
+++ b/src/librustc_mir/build/mod.rs
@@ -16,7 +16,6 @@ use rustc_span::symbol::kw;
 use rustc_span::Span;
 use rustc_target::spec::abi::Abi;
 use rustc_target::spec::PanicStrategy;
-use std::u32;
 use syntax::attr::{self, UnwindAttr};
 
 use super::lints;
diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs
index e94f263348d8a..19cce292a7fc0 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/hair/pattern/_match.rs b/src/librustc_mir/hair/pattern/_match.rs
index ffeb5e27ef191..34224ff73a915 100644
--- a/src/librustc_mir/hair/pattern/_match.rs
+++ b/src/librustc_mir/hair/pattern/_match.rs
@@ -258,7 +258,6 @@ use std::convert::TryInto;
 use std::fmt;
 use std::iter::{FromIterator, IntoIterator};
 use std::ops::RangeInclusive;
-use std::u128;
 
 pub fn expand_pattern<'a, 'tcx>(cx: &MatchCheckCtxt<'a, 'tcx>, pat: Pat<'tcx>) -> Pat<'tcx> {
     LiteralExpander { tcx: cx.tcx, param_env: cx.param_env }.fold_pattern(&pat)
diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs
index 819ed9a51e7bf..a286b12d449f5 100644
--- a/src/librustc_mir/transform/promote_consts.rs
+++ b/src/librustc_mir/transform/promote_consts.rs
@@ -27,7 +27,7 @@ use rustc_index::vec::{Idx, IndexVec};
 use rustc_target::spec::abi::Abi;
 
 use std::cell::Cell;
-use std::{iter, mem, usize};
+use std::{iter, mem};
 
 use crate::transform::check_consts::{is_lang_panic_fn, qualifs, ConstKind, Item};
 use crate::transform::{MirPass, MirSource};
diff --git a/src/librustc_passes/liveness.rs b/src/librustc_passes/liveness.rs
index 6a38524720e27..d6d97619fe143 100644
--- a/src/librustc_passes/liveness.rs
+++ b/src/librustc_passes/liveness.rs
@@ -109,10 +109,10 @@ use rustc_data_structures::fx::FxIndexMap;
 use rustc_span::symbol::sym;
 use rustc_span::Span;
 use std::collections::VecDeque;
+use std::fmt;
 use std::io;
 use std::io::prelude::*;
 use std::rc::Rc;
-use std::{fmt, u32};
 use syntax::ast;
 
 #[derive(Copy, Clone, PartialEq)]
diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs
index f60408334b686..62d8f4274e44f 100644
--- a/src/librustc_resolve/late.rs
+++ b/src/librustc_resolve/late.rs
@@ -1776,10 +1776,10 @@ impl<'a, 'b> LateResolutionVisitor<'a, '_> {
             // don't report an error right away, but try to fallback to a primitive type.
             // So, we are still able to successfully resolve something like
             //
-            // use std::u8; // bring module u8 in scope
-            // fn f() -> u8 { // OK, resolves to primitive u8, not to std::u8
+            // use u8; // bring module u8 in scope
+            // fn f() -> u8 { // OK, resolves to primitive u8, not to u8
             //     u8::MAX // OK, resolves to associated function <u8>::max_value,
-            //                     // not to non-existent std::u8::max_value
+            //                     // not to non-existent u8::max_value
             // }
             //
             // Such behavior is required for backward compatibility.
diff --git a/src/librustc_span/lib.rs b/src/librustc_span/lib.rs
index af7c5e6bd8a7e..6603a41c1bba6 100644
--- a/src/librustc_span/lib.rs
+++ b/src/librustc_span/lib.rs
@@ -1054,7 +1054,7 @@ impl Decodable for SourceFile {
                 // `crate_of_origin` has to be set by the importer.
                 // This value matches up with `rustc::hir::def_id::INVALID_CRATE`.
                 // That constant is not available here, unfortunately.
-                crate_of_origin: std::u32::MAX - 1,
+                crate_of_origin: u32::MAX - 1,
                 start_pos,
                 end_pos,
                 src: None,
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs
index bc39856e14d73..264eb9300d233 100644
--- a/src/librustc_typeck/collect.rs
+++ b/src/librustc_typeck/collect.rs
@@ -2866,13 +2866,13 @@ fn check_link_ordinal(tcx: TyCtxt<'_>, attr: &ast::Attribute) -> Option<usize> {
         _ => None,
     };
     if let Some(Lit { kind: LitKind::Int(ordinal, LitIntType::Unsuffixed), .. }) = sole_meta_list {
-        if *ordinal <= std::usize::MAX as u128 {
+        if *ordinal <= usize::MAX as u128 {
             Some(*ordinal as usize)
         } else {
             let msg = format!("ordinal value in `link_ordinal` is too large: `{}`", &ordinal);
             tcx.sess
                 .struct_span_err(attr.span, &msg)
-                .note("the value may not exceed `std::usize::MAX`")
+                .note("the value may not exceed `usize::MAX`")
                 .emit();
             None
         }
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index fad2bab43b990..5c721ab7c3e9e 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -32,7 +32,6 @@ use std::collections::hash_map::Entry;
 use std::default::Default;
 use std::hash::Hash;
 use std::rc::Rc;
-use std::u32;
 use std::{mem, vec};
 
 use crate::core::{self, DocContext, ImplTraitParam};
diff --git a/src/librustdoc/passes/unindent_comments.rs b/src/librustdoc/passes/unindent_comments.rs
index 3212af055efc5..d94069a83ff4e 100644
--- a/src/librustdoc/passes/unindent_comments.rs
+++ b/src/librustdoc/passes/unindent_comments.rs
@@ -1,6 +1,5 @@
 use std::cmp;
 use std::string::String;
-use std::usize;
 
 use crate::clean::{self, DocFragment, Item};
 use crate::core::DocContext;
diff --git a/src/libserialize/tests/json.rs b/src/libserialize/tests/json.rs
index c16426b5919c9..db2c172043e8b 100644
--- a/src/libserialize/tests/json.rs
+++ b/src/libserialize/tests/json.rs
@@ -17,7 +17,7 @@ use rustc_serialize::{Decodable, Encodable};
 use std::collections::BTreeMap;
 use std::io::prelude::*;
 use std::string;
-use std::{f32, f64, i64, u64};
+use std::{f32, f64};
 use Animal::*;
 
 #[derive(RustcDecodable, Eq, PartialEq, Debug)]
diff --git a/src/libserialize/tests/opaque.rs b/src/libserialize/tests/opaque.rs
index aa099bb8a3689..a6ec1580aca36 100644
--- a/src/libserialize/tests/opaque.rs
+++ b/src/libserialize/tests/opaque.rs
@@ -53,7 +53,7 @@ fn test_unit() {
 #[test]
 fn test_u8() {
     let mut vec = vec![];
-    for i in ::std::u8::MIN..::std::u8::MAX {
+    for i in u8::MIN..u8::MAX {
         vec.push(i);
     }
     check_round_trip(vec);
@@ -61,30 +61,30 @@ fn test_u8() {
 
 #[test]
 fn test_u16() {
-    for i in ::std::u16::MIN..::std::u16::MAX {
+    for i in u16::MIN..u16::MAX {
         check_round_trip(vec![1, 2, 3, i, i, i]);
     }
 }
 
 #[test]
 fn test_u32() {
-    check_round_trip(vec![1, 2, 3, ::std::u32::MIN, 0, 1, ::std::u32::MAX, 2, 1]);
+    check_round_trip(vec![1, 2, 3, u32::MIN, 0, 1, u32::MAX, 2, 1]);
 }
 
 #[test]
 fn test_u64() {
-    check_round_trip(vec![1, 2, 3, ::std::u64::MIN, 0, 1, ::std::u64::MAX, 2, 1]);
+    check_round_trip(vec![1, 2, 3, u64::MIN, 0, 1, u64::MAX, 2, 1]);
 }
 
 #[test]
 fn test_usize() {
-    check_round_trip(vec![1, 2, 3, ::std::usize::MIN, 0, 1, ::std::usize::MAX, 2, 1]);
+    check_round_trip(vec![1, 2, 3, usize::MIN, 0, 1, usize::MAX, 2, 1]);
 }
 
 #[test]
 fn test_i8() {
     let mut vec = vec![];
-    for i in ::std::i8::MIN..::std::i8::MAX {
+    for i in i8::MIN..i8::MAX {
         vec.push(i);
     }
     check_round_trip(vec);
@@ -92,24 +92,24 @@ fn test_i8() {
 
 #[test]
 fn test_i16() {
-    for i in ::std::i16::MIN..::std::i16::MAX {
+    for i in i16::MIN..i16::MAX {
         check_round_trip(vec![-1, 2, -3, i, i, i, 2]);
     }
 }
 
 #[test]
 fn test_i32() {
-    check_round_trip(vec![-1, 2, -3, ::std::i32::MIN, 0, 1, ::std::i32::MAX, 2, 1]);
+    check_round_trip(vec![-1, 2, -3, i32::MIN, 0, 1, i32::MAX, 2, 1]);
 }
 
 #[test]
 fn test_i64() {
-    check_round_trip(vec![-1, 2, -3, ::std::i64::MIN, 0, 1, ::std::i64::MAX, 2, 1]);
+    check_round_trip(vec![-1, 2, -3, i64::MIN, 0, 1, i64::MAX, 2, 1]);
 }
 
 #[test]
 fn test_isize() {
-    check_round_trip(vec![-1, 2, -3, ::std::isize::MIN, 0, 1, ::std::isize::MAX, 2, 1]);
+    check_round_trip(vec![-1, 2, -3, isize::MIN, 0, 1, isize::MAX, 2, 1]);
 }
 
 #[test]
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index fdc587ba5dacf..bafcc7f5b16d6 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -2619,7 +2619,7 @@ mod test_map {
     use crate::cell::RefCell;
     use rand::{thread_rng, Rng};
     use realstd::collections::TryReserveError::*;
-    use realstd::usize;
+    use realusize;
 
     // https://github.com/rust-lang/rust/issues/62301
     fn _assert_hashmap_is_unwind_safe() {
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index f90647472c678..b2d4b7e83992e 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -63,7 +63,7 @@
 //! So for example there is a [page for the primitive type
 //! `i32`](primitive.i32.html) that lists all the methods that can be called on
 //! 32-bit integers (very useful), and there is a [page for the module
-//! `std::i32`](i32/index.html) that documents the constant values [`MIN`] and
+//! `i32`](i32/index.html) that documents the constant values [`MIN`] and
 //! [`MAX`](i32/constant.MAX.html) (rarely useful).
 //!
 //! Note the documentation for the primitives [`str`] and [`[T]`][slice] (also
@@ -400,18 +400,30 @@ pub use core::hash;
 #[stable(feature = "core_hint", since = "1.27.0")]
 pub use core::hint;
 #[stable(feature = "i128", since = "1.26.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::i128;
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::i16;
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::i32;
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::i64;
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::i8;
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use core::intrinsics;
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::isize;
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use core::iter;
@@ -432,16 +444,28 @@ pub use core::raw;
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use core::result;
 #[stable(feature = "i128", since = "1.26.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::u128;
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::u16;
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::u32;
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::u64;
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::u8;
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::usize;
 
 pub mod f32;
diff --git a/src/libstd/sync/mpsc/shared.rs b/src/libstd/sync/mpsc/shared.rs
index 2b0393573fdc4..c4e929624d7a4 100644
--- a/src/libstd/sync/mpsc/shared.rs
+++ b/src/libstd/sync/mpsc/shared.rs
@@ -12,7 +12,6 @@ use self::StartResult::*;
 
 use core::cmp;
 use core::intrinsics::abort;
-use core::isize;
 
 use crate::cell::UnsafeCell;
 use crate::ptr;
diff --git a/src/libstd/sync/mpsc/stream.rs b/src/libstd/sync/mpsc/stream.rs
index 2e3270e81fcd0..f33493ee0c9c9 100644
--- a/src/libstd/sync/mpsc/stream.rs
+++ b/src/libstd/sync/mpsc/stream.rs
@@ -11,7 +11,6 @@ use self::Message::*;
 pub use self::UpgradeResult::*;
 
 use core::cmp;
-use core::isize;
 
 use crate::cell::UnsafeCell;
 use crate::ptr;
diff --git a/src/libstd/sync/mpsc/sync.rs b/src/libstd/sync/mpsc/sync.rs
index 79e868171546b..3e2050799ccb4 100644
--- a/src/libstd/sync/mpsc/sync.rs
+++ b/src/libstd/sync/mpsc/sync.rs
@@ -26,7 +26,6 @@ use self::Blocker::*;
 pub use self::Failure::*;
 
 use core::intrinsics::abort;
-use core::isize;
 use core::mem;
 use core::ptr;
 
diff --git a/src/libstd/sys/hermit/thread.rs b/src/libstd/sys/hermit/thread.rs
index c3c29c93826de..cc99b85422237 100644
--- a/src/libstd/sys/hermit/thread.rs
+++ b/src/libstd/sys/hermit/thread.rs
@@ -6,7 +6,6 @@ use crate::io;
 use crate::mem;
 use crate::sys::hermit::abi;
 use crate::time::Duration;
-use core::u32;
 
 use crate::sys_common::thread::*;
 
diff --git a/src/libstd/sys/unix/process/zircon.rs b/src/libstd/sys/unix/process/zircon.rs
index 750b8f0762ae5..7ed41f3f1d29b 100644
--- a/src/libstd/sys/unix/process/zircon.rs
+++ b/src/libstd/sys/unix/process/zircon.rs
@@ -1,7 +1,6 @@
 #![allow(non_camel_case_types, unused)]
 
 use crate::convert::TryInto;
-use crate::i64;
 use crate::io;
 use crate::mem::MaybeUninit;
 use crate::os::raw::c_char;
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs
index b17418911380d..ef130458f4a45 100644
--- a/src/libstd/thread/mod.rs
+++ b/src/libstd/thread/mod.rs
@@ -1062,7 +1062,7 @@ impl ThreadId {
 
             // If we somehow use up all our bits, panic so that we're not
             // covering up subtle bugs of IDs being reused.
-            if COUNTER == crate::u64::MAX {
+            if COUNTER == u64::MAX {
                 panic!("failed to generate unique thread ID: bitspace exhausted");
             }
 
diff --git a/src/libsyntax/attr/mod.rs b/src/libsyntax/attr/mod.rs
index 8449b61f7b0bb..ccbf91035cda4 100644
--- a/src/libsyntax/attr/mod.rs
+++ b/src/libsyntax/attr/mod.rs
@@ -344,7 +344,7 @@ crate fn mk_attr_id() -> AttrId {
     static NEXT_ATTR_ID: AtomicUsize = AtomicUsize::new(0);
 
     let id = NEXT_ATTR_ID.fetch_add(1, Ordering::SeqCst);
-    assert!(id != ::std::usize::MAX);
+    assert!(id != usize::MAX);
     AttrId(id)
 }
 
diff --git a/src/libsyntax/util/comments.rs b/src/libsyntax/util/comments.rs
index c385b498ced72..753a928975781 100644
--- a/src/libsyntax/util/comments.rs
+++ b/src/libsyntax/util/comments.rs
@@ -6,8 +6,6 @@ use crate::sess::ParseSess;
 use rustc_span::source_map::SourceMap;
 use rustc_span::{BytePos, CharPos, FileName, Pos};
 
-use std::usize;
-
 use log::debug;
 
 #[cfg(test)]
diff --git a/src/test/codegen/issue-56927.rs b/src/test/codegen/issue-56927.rs
index 0544ff86aacfa..b1e4eaf1061df 100644
--- a/src/test/codegen/issue-56927.rs
+++ b/src/test/codegen/issue-56927.rs
@@ -1,7 +1,6 @@
 // compile-flags: -C no-prepopulate-passes
 
 #![crate_type="rlib"]
-use std::usize;
 
 #[repr(align(16))]
 pub struct S {
diff --git a/src/test/compile-fail/consts/issue-55878.rs b/src/test/compile-fail/consts/issue-55878.rs
index aa1dd58d2463d..9669cb8110d75 100644
--- a/src/test/compile-fail/consts/issue-55878.rs
+++ b/src/test/compile-fail/consts/issue-55878.rs
@@ -3,5 +3,5 @@
 
 // error-pattern: is too big for the current architecture
 fn main() {
-    println!("Size: {}", std::mem::size_of::<[u8; std::u64::MAX as usize]>());
+    println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
 }
diff --git a/src/test/run-fail/bounds-check-no-overflow.rs b/src/test/run-fail/bounds-check-no-overflow.rs
index 3943f87f7fe0c..c46af8002e3ff 100644
--- a/src/test/run-fail/bounds-check-no-overflow.rs
+++ b/src/test/run-fail/bounds-check-no-overflow.rs
@@ -1,6 +1,5 @@
 // error-pattern:index out of bounds
 
-use std::usize;
 use std::mem::size_of;
 
 fn main() {
diff --git a/src/test/run-fail/hashmap-capacity-overflow.rs b/src/test/run-fail/hashmap-capacity-overflow.rs
index 038f2756ff322..806db300c04f1 100644
--- a/src/test/run-fail/hashmap-capacity-overflow.rs
+++ b/src/test/run-fail/hashmap-capacity-overflow.rs
@@ -1,7 +1,6 @@
 // error-pattern:capacity overflow
 
 use std::collections::hash_map::HashMap;
-use std::usize;
 use std::mem::size_of;
 
 fn main() {
diff --git a/src/test/run-fail/overflowing-neg.rs b/src/test/run-fail/overflowing-neg.rs
index c4afd74241eda..d5afd782603c8 100644
--- a/src/test/run-fail/overflowing-neg.rs
+++ b/src/test/run-fail/overflowing-neg.rs
@@ -4,5 +4,5 @@
 #![allow(const_err)]
 
 fn main() {
-    let _x = -std::i8::MIN;
+    let _x = -i8::MIN;
 }
diff --git a/src/test/ui/consts/const-err-early.rs b/src/test/ui/consts/const-err-early.rs
index bae2cd286e1c9..13dfe7fac9900 100644
--- a/src/test/ui/consts/const-err-early.rs
+++ b/src/test/ui/consts/const-err-early.rs
@@ -1,6 +1,6 @@
 #![deny(const_err)]
 
-pub const A: i8 = -std::i8::MIN; //~ ERROR const_err
+pub const A: i8 = -i8::MIN; //~ ERROR const_err
 pub const B: u8 = 200u8 + 200u8; //~ ERROR const_err
 pub const C: u8 = 200u8 * 4; //~ ERROR const_err
 pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err
diff --git a/src/test/ui/consts/const-err-early.stderr b/src/test/ui/consts/const-err-early.stderr
index 9b0ef94a5b8c3..2637471d01fa8 100644
--- a/src/test/ui/consts/const-err-early.stderr
+++ b/src/test/ui/consts/const-err-early.stderr
@@ -1,7 +1,7 @@
 error: any use of this value will cause an error
   --> $DIR/const-err-early.rs:3:19
    |
-LL | pub const A: i8 = -std::i8::MIN;
+LL | pub const A: i8 = -i8::MIN;
    | ------------------^^^^^^^^^^^^^-
    |                   |
    |                   attempt to negate with overflow
diff --git a/src/test/ui/consts/const-err-multi.rs b/src/test/ui/consts/const-err-multi.rs
index fa3ad832c60e2..ce74fae98162d 100644
--- a/src/test/ui/consts/const-err-multi.rs
+++ b/src/test/ui/consts/const-err-multi.rs
@@ -1,6 +1,6 @@
 #![deny(const_err)]
 
-pub const A: i8 = -std::i8::MIN;
+pub const A: i8 = -i8::MIN;
 //~^ ERROR const_err
 pub const B: i8 = A;
 //~^ ERROR const_err
diff --git a/src/test/ui/consts/const-err-multi.stderr b/src/test/ui/consts/const-err-multi.stderr
index c647f13fc7520..3b1613af76c26 100644
--- a/src/test/ui/consts/const-err-multi.stderr
+++ b/src/test/ui/consts/const-err-multi.stderr
@@ -1,7 +1,7 @@
 error: any use of this value will cause an error
   --> $DIR/const-err-multi.rs:3:19
    |
-LL | pub const A: i8 = -std::i8::MIN;
+LL | pub const A: i8 = -i8::MIN;
    | ------------------^^^^^^^^^^^^^-
    |                   |
    |                   attempt to negate with overflow
diff --git a/src/test/ui/consts/const-err2.rs b/src/test/ui/consts/const-err2.rs
index 351dfd2e0f58c..6572f69037a90 100644
--- a/src/test/ui/consts/const-err2.rs
+++ b/src/test/ui/consts/const-err2.rs
@@ -15,7 +15,7 @@ fn black_box<T>(_: T) {
 }
 
 fn main() {
-    let a = -std::i8::MIN;
+    let a = -i8::MIN;
     //~^ ERROR const_err
     let b = 200u8 + 200u8 + 200u8;
     //~^ ERROR const_err
diff --git a/src/test/ui/consts/const-err2.stderr b/src/test/ui/consts/const-err2.stderr
index 2ca1019d4947b..1bf50192fb1ba 100644
--- a/src/test/ui/consts/const-err2.stderr
+++ b/src/test/ui/consts/const-err2.stderr
@@ -1,7 +1,7 @@
 error: this expression will panic at runtime
   --> $DIR/const-err2.rs:18:13
    |
-LL |     let a = -std::i8::MIN;
+LL |     let a = -i8::MIN;
    |             ^^^^^^^^^^^^^ attempt to negate with overflow
    |
 note: lint level defined here
diff --git a/src/test/ui/consts/const-err3.rs b/src/test/ui/consts/const-err3.rs
index ab3823efd301d..abd9f11f02b26 100644
--- a/src/test/ui/consts/const-err3.rs
+++ b/src/test/ui/consts/const-err3.rs
@@ -15,7 +15,7 @@ fn black_box<T>(_: T) {
 }
 
 fn main() {
-    let a = -std::i8::MIN;
+    let a = -i8::MIN;
     //~^ ERROR const_err
     let b = 200u8 + 200u8 + 200u8;
     //~^ ERROR const_err
diff --git a/src/test/ui/consts/const-err3.stderr b/src/test/ui/consts/const-err3.stderr
index c374637bec267..5ca70857d2ad2 100644
--- a/src/test/ui/consts/const-err3.stderr
+++ b/src/test/ui/consts/const-err3.stderr
@@ -1,7 +1,7 @@
 error: attempt to negate with overflow
   --> $DIR/const-err3.rs:18:13
    |
-LL |     let a = -std::i8::MIN;
+LL |     let a = -i8::MIN;
    |             ^^^^^^^^^^^^^
    |
 note: lint level defined here
diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-2.rs b/src/test/ui/consts/const-eval/const-eval-overflow-2.rs
index 9369702f1721c..244fba378cb7b 100644
--- a/src/test/ui/consts/const-eval/const-eval-overflow-2.rs
+++ b/src/test/ui/consts/const-eval/const-eval-overflow-2.rs
@@ -4,8 +4,6 @@
 #![allow(unused_imports, warnings, const_err)]
 
 use std::fmt;
-use std::{i8, i16, i32, i64, isize};
-use std::{u8, u16, u32, u64, usize};
 
 const NEG_128: i8 = -128;
 const NEG_NEG_128: i8 = -NEG_128;
diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-3.rs b/src/test/ui/consts/const-eval/const-eval-overflow-3.rs
index 6fd8e9cbc806b..bcc966dc9621c 100644
--- a/src/test/ui/consts/const-eval/const-eval-overflow-3.rs
+++ b/src/test/ui/consts/const-eval/const-eval-overflow-3.rs
@@ -12,8 +12,6 @@
 #![allow(unused_imports)]
 
 use std::fmt;
-use std::{i8, i16, i32, i64, isize};
-use std::{u8, u16, u32, u64, usize};
 
 const A_I8_I
     : [u32; (i8::MAX as usize) + 1]
diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-3b.rs b/src/test/ui/consts/const-eval/const-eval-overflow-3b.rs
index db6f17a671aea..480069e67fa28 100644
--- a/src/test/ui/consts/const-eval/const-eval-overflow-3b.rs
+++ b/src/test/ui/consts/const-eval/const-eval-overflow-3b.rs
@@ -10,8 +10,6 @@
 #![allow(unused_imports)]
 
 use std::fmt;
-use std::{i8, i16, i32, i64, isize};
-use std::{u8, u16, u32, u64, usize};
 
 const A_I8_I
     : [u32; (i8::MAX as usize) + 1]
diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-4.rs b/src/test/ui/consts/const-eval/const-eval-overflow-4.rs
index 0b12a438f9662..762c7a968a8ff 100644
--- a/src/test/ui/consts/const-eval/const-eval-overflow-4.rs
+++ b/src/test/ui/consts/const-eval/const-eval-overflow-4.rs
@@ -6,8 +6,6 @@
 #![allow(unused_imports)]
 
 use std::fmt;
-use std::{i8, i16, i32, i64, isize};
-use std::{u8, u16, u32, u64, usize};
 
 const A_I8_T
     : [u32; (i8::MAX as i8 + 1i8) as usize]
diff --git a/src/test/ui/consts/const-eval/const-eval-overflow-4b.rs b/src/test/ui/consts/const-eval/const-eval-overflow-4b.rs
index 2a4585faf1493..ce9c980de0dd2 100644
--- a/src/test/ui/consts/const-eval/const-eval-overflow-4b.rs
+++ b/src/test/ui/consts/const-eval/const-eval-overflow-4b.rs
@@ -5,9 +5,6 @@
 
 #![allow(unused_imports)]
 
-use std::{i8, i16, i32, i64, isize};
-use std::{u8, u16, u32, u64, usize};
-
 const A_I8_T
     : [u32; (i8::MAX as i8 + 1u8) as usize]
     //~^ ERROR mismatched types
diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2.rs b/src/test/ui/consts/const-eval/const-eval-overflow2.rs
index a0dbcc88cea8a..57a9dd55c8b55 100644
--- a/src/test/ui/consts/const-eval/const-eval-overflow2.rs
+++ b/src/test/ui/consts/const-eval/const-eval-overflow2.rs
@@ -8,8 +8,6 @@
 #![deny(const_err)]
 
 use std::fmt;
-use std::{i8, i16, i32, i64, isize};
-use std::{u8, u16, u32, u64, usize};
 
 const VALS_I8: (i8,) =
     (
diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs
index da883671a60a3..e87952ab0f438 100644
--- a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs
+++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs
@@ -8,8 +8,6 @@
 #![deny(const_err)]
 
 use std::fmt;
-use std::{i8, i16, i32, i64, isize};
-use std::{u8, u16, u32, u64, usize};
 
 const VALS_I8: (i8,) =
     (
diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs
index e87344405a103..84d3dd20a924e 100644
--- a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs
+++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs
@@ -8,8 +8,6 @@
 #![deny(const_err)]
 
 use std::fmt;
-use std::{i8, i16, i32, i64, isize};
-use std::{u8, u16, u32, u64, usize};
 
 const VALS_I8: (i8,) =
     (
diff --git a/src/test/ui/consts/const-eval/dangling.rs b/src/test/ui/consts/const-eval/dangling.rs
index b5d72d46f2861..6e4be7f0e06ad 100644
--- a/src/test/ui/consts/const-eval/dangling.rs
+++ b/src/test/ui/consts/const-eval/dangling.rs
@@ -1,6 +1,6 @@
 #![feature(const_transmute, const_raw_ptr_deref)]
 
-use std::{mem, usize};
+use std::mem;
 
 // Make sure we error with the right kind of error on a too large slice.
 const TEST: () = { unsafe { //~ NOTE
diff --git a/src/test/ui/consts/const-int-overflowing-rpass.rs b/src/test/ui/consts/const-int-overflowing-rpass.rs
index eecb88becabca..75e77fdf1be17 100644
--- a/src/test/ui/consts/const-int-overflowing-rpass.rs
+++ b/src/test/ui/consts/const-int-overflowing-rpass.rs
@@ -16,7 +16,7 @@ const SHR_A: (u32, bool) = 0x10u32.overflowing_shr(4);
 const SHR_B: (u32, bool) = 0x10u32.overflowing_shr(132);
 
 const NEG_A: (u32, bool) = 0u32.overflowing_neg();
-const NEG_B: (u32, bool) = core::u32::MAX.overflowing_neg();
+const NEG_B: (u32, bool) = u32::MAX.overflowing_neg();
 
 const ABS_POS: (i32, bool) = 10i32.overflowing_abs();
 const ABS_NEG: (i32, bool) = (-10i32).overflowing_abs();
diff --git a/src/test/ui/consts/const-match-check.eval1.stderr b/src/test/ui/consts/const-match-check.eval1.stderr
index 087cc3c86a68d..bcdeac80d2dbb 100644
--- a/src/test/ui/consts/const-match-check.eval1.stderr
+++ b/src/test/ui/consts/const-match-check.eval1.stderr
@@ -1,8 +1,8 @@
-error[E0005]: refutable pattern in local binding: `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+error[E0005]: refutable pattern in local binding: `i32::MIN..=-1i32` and `1i32..=i32::MAX` not covered
   --> $DIR/const-match-check.rs:25:15
    |
 LL |     A = { let 0 = 0; 0 },
-   |               ^ patterns `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+   |               ^ patterns `i32::MIN..=-1i32` and `1i32..=i32::MAX` not covered
    |
    = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
    = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
diff --git a/src/test/ui/consts/const-match-check.eval2.stderr b/src/test/ui/consts/const-match-check.eval2.stderr
index 80d9f794bc1d5..993dbe944bcc1 100644
--- a/src/test/ui/consts/const-match-check.eval2.stderr
+++ b/src/test/ui/consts/const-match-check.eval2.stderr
@@ -1,8 +1,8 @@
-error[E0005]: refutable pattern in local binding: `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+error[E0005]: refutable pattern in local binding: `i32::MIN..=-1i32` and `1i32..=i32::MAX` not covered
   --> $DIR/const-match-check.rs:31:24
    |
 LL |     let x: [i32; { let 0 = 0; 0 }] = [];
-   |                        ^ patterns `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+   |                        ^ patterns `i32::MIN..=-1i32` and `1i32..=i32::MAX` not covered
    |
    = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
    = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
diff --git a/src/test/ui/consts/const-match-check.matchck.stderr b/src/test/ui/consts/const-match-check.matchck.stderr
index e6b2f212bb430..da43563f044b1 100644
--- a/src/test/ui/consts/const-match-check.matchck.stderr
+++ b/src/test/ui/consts/const-match-check.matchck.stderr
@@ -1,8 +1,8 @@
-error[E0005]: refutable pattern in local binding: `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+error[E0005]: refutable pattern in local binding: `i32::MIN..=-1i32` and `1i32..=i32::MAX` not covered
   --> $DIR/const-match-check.rs:4:22
    |
 LL | const X: i32 = { let 0 = 0; 0 };
-   |                      ^ patterns `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+   |                      ^ patterns `i32::MIN..=-1i32` and `1i32..=i32::MAX` not covered
    |
    = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
    = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
@@ -11,11 +11,11 @@ help: you might want to use `if let` to ignore the variant that isn't matched
 LL | const X: i32 = { if let 0 = 0 { /* */ } 0 };
    |                  ^^^^^^^^^^^^^^^^^^^^^^
 
-error[E0005]: refutable pattern in local binding: `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+error[E0005]: refutable pattern in local binding: `i32::MIN..=-1i32` and `1i32..=i32::MAX` not covered
   --> $DIR/const-match-check.rs:8:23
    |
 LL | static Y: i32 = { let 0 = 0; 0 };
-   |                       ^ patterns `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+   |                       ^ patterns `i32::MIN..=-1i32` and `1i32..=i32::MAX` not covered
    |
    = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
    = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
@@ -24,11 +24,11 @@ help: you might want to use `if let` to ignore the variant that isn't matched
 LL | static Y: i32 = { if let 0 = 0 { /* */ } 0 };
    |                   ^^^^^^^^^^^^^^^^^^^^^^
 
-error[E0005]: refutable pattern in local binding: `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+error[E0005]: refutable pattern in local binding: `i32::MIN..=-1i32` and `1i32..=i32::MAX` not covered
   --> $DIR/const-match-check.rs:13:26
    |
 LL |     const X: i32 = { let 0 = 0; 0 };
-   |                          ^ patterns `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+   |                          ^ patterns `i32::MIN..=-1i32` and `1i32..=i32::MAX` not covered
    |
    = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
    = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
@@ -37,11 +37,11 @@ help: you might want to use `if let` to ignore the variant that isn't matched
 LL |     const X: i32 = { if let 0 = 0 { /* */ } 0 };
    |                      ^^^^^^^^^^^^^^^^^^^^^^
 
-error[E0005]: refutable pattern in local binding: `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+error[E0005]: refutable pattern in local binding: `i32::MIN..=-1i32` and `1i32..=i32::MAX` not covered
   --> $DIR/const-match-check.rs:19:26
    |
 LL |     const X: i32 = { let 0 = 0; 0 };
-   |                          ^ patterns `std::i32::MIN..=-1i32` and `1i32..=std::i32::MAX` not covered
+   |                          ^ patterns `i32::MIN..=-1i32` and `1i32..=i32::MAX` not covered
    |
    = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
    = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
diff --git a/src/test/ui/consts/const-negation.rs b/src/test/ui/consts/const-negation.rs
index 1c8e27ae6172a..26c3c0b836bec 100644
--- a/src/test/ui/consts/const-negation.rs
+++ b/src/test/ui/consts/const-negation.rs
@@ -8,19 +8,19 @@ fn main() {
     const I: isize = -2147483648isize;
     #[cfg(target_pointer_width = "64")]
     const I: isize = -9223372036854775808isize;
-    assert_eq!(::std::i32::MIN as u64, 0xffffffff80000000);
+    assert_eq!(i32::MIN as u64, 0xffffffff80000000);
     assert_eq!(-2147483648isize as u64, 0xffffffff80000000);
     assert_eq!(-2147483648i32 as u64, 0xffffffff80000000);
-    assert_eq!(::std::i64::MIN as u64, 0x8000000000000000);
+    assert_eq!(i64::MIN as u64, 0x8000000000000000);
     #[cfg(target_pointer_width = "64")]
     assert_eq!(-9223372036854775808isize as u64, 0x8000000000000000);
     #[cfg(target_pointer_width = "32")]
     assert_eq!(-9223372036854775808isize as u64, 0);
     assert_eq!(-9223372036854775808i32 as u64, 0);
-    const J: usize = ::std::i32::MAX as usize;
+    const J: usize = i32::MAX as usize;
     const K: usize = -1i32 as u32 as usize;
-    const L: usize = ::std::i32::MIN as usize;
-    const M: usize = ::std::i64::MIN as usize;
+    const L: usize = i32::MIN as usize;
+    const M: usize = i64::MIN as usize;
     match 5 {
         J => {},
         K => {},
diff --git a/src/test/ui/consts/const-pattern-irrefutable.rs b/src/test/ui/consts/const-pattern-irrefutable.rs
index 60e16aaf89532..65f09eb80098c 100644
--- a/src/test/ui/consts/const-pattern-irrefutable.rs
+++ b/src/test/ui/consts/const-pattern-irrefutable.rs
@@ -9,8 +9,8 @@ use foo::d;
 const a: u8 = 2;
 
 fn main() {
-    let a = 4; //~ ERROR refutable pattern in local binding: `0u8..=1u8` and `3u8..=std::u8::MAX
-    let c = 4; //~ ERROR refutable pattern in local binding: `0u8..=1u8` and `3u8..=std::u8::MAX
-    let d = 4; //~ ERROR refutable pattern in local binding: `0u8..=1u8` and `3u8..=std::u8::MAX
+    let a = 4; //~ ERROR refutable pattern in local binding: `0u8..=1u8` and `3u8..=u8::MAX
+    let c = 4; //~ ERROR refutable pattern in local binding: `0u8..=1u8` and `3u8..=u8::MAX
+    let d = 4; //~ ERROR refutable pattern in local binding: `0u8..=1u8` and `3u8..=u8::MAX
     fn f() {} // Check that the `NOTE`s still work with an item here (cf. issue #35115).
 }
diff --git a/src/test/ui/consts/const-pattern-irrefutable.stderr b/src/test/ui/consts/const-pattern-irrefutable.stderr
index 4814aa9a5b2ca..c9064aef5afc6 100644
--- a/src/test/ui/consts/const-pattern-irrefutable.stderr
+++ b/src/test/ui/consts/const-pattern-irrefutable.stderr
@@ -1,4 +1,4 @@
-error[E0005]: refutable pattern in local binding: `0u8..=1u8` and `3u8..=std::u8::MAX` not covered
+error[E0005]: refutable pattern in local binding: `0u8..=1u8` and `3u8..=u8::MAX` not covered
   --> $DIR/const-pattern-irrefutable.rs:12:9
    |
 LL | const a: u8 = 2;
@@ -10,7 +10,7 @@ LL |     let a = 4;
    |         interpreted as a constant pattern, not a new variable
    |         help: introduce a variable instead: `a_var`
 
-error[E0005]: refutable pattern in local binding: `0u8..=1u8` and `3u8..=std::u8::MAX` not covered
+error[E0005]: refutable pattern in local binding: `0u8..=1u8` and `3u8..=u8::MAX` not covered
   --> $DIR/const-pattern-irrefutable.rs:13:9
    |
 LL |     pub const b: u8 = 2;
@@ -22,7 +22,7 @@ LL |     let c = 4;
    |         interpreted as a constant pattern, not a new variable
    |         help: introduce a variable instead: `c_var`
 
-error[E0005]: refutable pattern in local binding: `0u8..=1u8` and `3u8..=std::u8::MAX` not covered
+error[E0005]: refutable pattern in local binding: `0u8..=1u8` and `3u8..=u8::MAX` not covered
   --> $DIR/const-pattern-irrefutable.rs:14:9
    |
 LL |     pub const d: u8 = 2;
diff --git a/src/test/ui/consts/promotion.rs b/src/test/ui/consts/promotion.rs
index 3c5401e421216..7b343e6dfe084 100644
--- a/src/test/ui/consts/promotion.rs
+++ b/src/test/ui/consts/promotion.rs
@@ -13,5 +13,5 @@ fn main() {
 
     // make sure that these do not cause trouble despite overflowing
     baz_u32(&(0-1));
-    baz_i32(&-std::i32::MIN);
+    baz_i32(&-i32::MIN);
 }
diff --git a/src/test/ui/discrim/discrim-ill-typed.rs b/src/test/ui/discrim/discrim-ill-typed.rs
index 98c90f0ea6828..3cf0ea0e6b997 100644
--- a/src/test/ui/discrim/discrim-ill-typed.rs
+++ b/src/test/ui/discrim/discrim-ill-typed.rs
@@ -7,8 +7,6 @@
 
 #![allow(dead_code, unused_variables, unused_imports)]
 
-use std::{i8,u8,i16,u16,i32,u32,i64, u64};
-
 fn f_i8() {
     #[repr(i8)]
     enum A {
diff --git a/src/test/ui/discrim/discrim-overflow-2.rs b/src/test/ui/discrim/discrim-overflow-2.rs
index f8f565f4d9c14..ca24317c54dc2 100644
--- a/src/test/ui/discrim/discrim-overflow-2.rs
+++ b/src/test/ui/discrim/discrim-overflow-2.rs
@@ -5,8 +5,6 @@
 // See also run-pass/discrim-explicit-23030.rs where the suggested
 // workaround is tested.
 
-use std::{i8,u8,i16,u16,i32,u32,i64, u64};
-
 fn f_i8() {
     #[repr(i8)]
     enum A {
diff --git a/src/test/ui/discrim/discrim-overflow.rs b/src/test/ui/discrim/discrim-overflow.rs
index d8a9dacfa5180..774ced93c1723 100644
--- a/src/test/ui/discrim/discrim-overflow.rs
+++ b/src/test/ui/discrim/discrim-overflow.rs
@@ -3,8 +3,6 @@
 // See also run-pass/discrim-explicit-23030.rs where the suggested
 // workaround is tested.
 
-use std::{i8,u8,i16,u16,i32,u32,i64, u64};
-
 fn f_i8() {
     #[repr(i8)]
     enum A {
diff --git a/src/test/ui/drop/dynamic-drop-async.rs b/src/test/ui/drop/dynamic-drop-async.rs
index 91063edf0f6c4..31240c74a4745 100644
--- a/src/test/ui/drop/dynamic-drop-async.rs
+++ b/src/test/ui/drop/dynamic-drop-async.rs
@@ -19,7 +19,6 @@ use std::{
     ptr,
     rc::Rc,
     task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
-    usize,
 };
 
 struct InjectedFailure;
diff --git a/src/test/ui/drop/dynamic-drop.rs b/src/test/ui/drop/dynamic-drop.rs
index 0f0ec0ba460c8..f570b2e162f13 100644
--- a/src/test/ui/drop/dynamic-drop.rs
+++ b/src/test/ui/drop/dynamic-drop.rs
@@ -12,7 +12,6 @@ use std::mem::ManuallyDrop;
 use std::ops::Generator;
 use std::panic;
 use std::pin::Pin;
-use std::usize;
 
 struct InjectedFailure;
 
diff --git a/src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.rs b/src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.rs
index 1208552d25637..54d0e49c8c58e 100644
--- a/src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.rs
+++ b/src/test/ui/feature-gates/feature-gate-precise_pointer_size_matching.rs
@@ -1,10 +1,8 @@
 #![feature(exclusive_range_pattern)]
 
-use std::usize::MAX;
-
 fn main() {
     match 0usize { //~ERROR non-exhaustive patterns: `_` not covered
-        0..=MAX => {}
+        0..=usize::MAX => {}
     }
 
     match 0isize { //~ERROR non-exhaustive patterns: `_` not covered
diff --git a/src/test/ui/for/for-loop-refutable-pattern-error-message.stderr b/src/test/ui/for/for-loop-refutable-pattern-error-message.stderr
index 14aea2dc27eea..365cb2ae5bc11 100644
--- a/src/test/ui/for/for-loop-refutable-pattern-error-message.stderr
+++ b/src/test/ui/for/for-loop-refutable-pattern-error-message.stderr
@@ -1,8 +1,8 @@
-error[E0005]: refutable pattern in `for` loop binding: `&std::i32::MIN..=0i32` and `&2i32..=std::i32::MAX` not covered
+error[E0005]: refutable pattern in `for` loop binding: `&i32::MIN..=0i32` and `&2i32..=i32::MAX` not covered
   --> $DIR/for-loop-refutable-pattern-error-message.rs:2:9
    |
 LL |     for &1 in [1].iter() {}
-   |         ^^ patterns `&std::i32::MIN..=0i32` and `&2i32..=std::i32::MAX` not covered
+   |         ^^ patterns `&i32::MIN..=0i32` and `&2i32..=i32::MAX` not covered
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/ifmt.rs b/src/test/ui/ifmt.rs
index 1a070843cc446..da05238559f2d 100644
--- a/src/test/ui/ifmt.rs
+++ b/src/test/ui/ifmt.rs
@@ -7,7 +7,6 @@
 
 use std::cell::RefCell;
 use std::fmt::{self, Write};
-use std::usize;
 
 struct A;
 struct B;
diff --git a/src/test/ui/issues/issue-22933-3.stderr b/src/test/ui/issues/issue-22933-3.stderr
index 72bca3b040839..ed4f768cd275b 100644
--- a/src/test/ui/issues/issue-22933-3.stderr
+++ b/src/test/ui/issues/issue-22933-3.stderr
@@ -6,7 +6,7 @@ LL | const FOO: [u32; u8::MIN as usize] = [];
    |
 help: you are looking for the module in `std`, not the primitive type
    |
-LL | const FOO: [u32; std::u8::MIN as usize] = [];
+LL | const FOO: [u32; u8::MIN as usize] = [];
    |                  ^^^^^^^^^^^^
 
 error: aborting due to previous error
diff --git a/src/test/ui/issues/issue-23833.rs b/src/test/ui/issues/issue-23833.rs
index 77dc5c50d7aba..d4128fa54e3da 100644
--- a/src/test/ui/issues/issue-23833.rs
+++ b/src/test/ui/issues/issue-23833.rs
@@ -1,8 +1,6 @@
 // run-pass
 #![allow(unused_imports)]
 use std::fmt;
-use std::{i8, i16, i32, i64, isize};
-use std::{u8, u16, u32, u64, usize};
 
 const A_I8_T
     : [u32; (i8::MAX as i8 - 1i8) as usize]
diff --git a/src/test/ui/issues/issue-37686.rs b/src/test/ui/issues/issue-37686.rs
index 8c3762514494a..ba58e9e9d8976 100644
--- a/src/test/ui/issues/issue-37686.rs
+++ b/src/test/ui/issues/issue-37686.rs
@@ -1,7 +1,7 @@
 // run-pass
 fn main() {
     match (0, 0) {
-        (std::usize::MIN, std::usize::MAX) => {}
+        (usize::MIN, usize::MAX) => {}
         _ => {}
     }
 }
diff --git a/src/test/ui/issues/issue-41880.rs b/src/test/ui/issues/issue-41880.rs
index 16facc5a78f8d..37f2729a2b0a9 100644
--- a/src/test/ui/issues/issue-41880.rs
+++ b/src/test/ui/issues/issue-41880.rs
@@ -19,7 +19,7 @@ impl<T: Clone, F> Iterator for Iterate<T, F> where F: Fn(&T) -> T {
         Some(self.state.clone())
     }
     #[inline]
-    fn size_hint(&self) -> (usize, Option<usize>) { (std::usize::MAX, None) }
+    fn size_hint(&self) -> (usize, Option<usize>) { (usize::MAX, None) }
 }
 
 fn main() {
diff --git a/src/test/ui/issues/issue-48006.rs b/src/test/ui/issues/issue-48006.rs
index 3a862ace55ecc..cfef270e5a67c 100644
--- a/src/test/ui/issues/issue-48006.rs
+++ b/src/test/ui/issues/issue-48006.rs
@@ -6,10 +6,10 @@ use std::iter::Step;
 
 #[cfg(target_pointer_width = "16")]
 fn main() {
-    assert!(Step::steps_between(&0u32, &::std::u32::MAX).is_none());
+    assert!(Step::steps_between(&0u32, &u32::MAX).is_none());
 }
 
 #[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))]
 fn main() {
-    assert!(Step::steps_between(&0u32, &::std::u32::MAX).is_some());
+    assert!(Step::steps_between(&0u32, &u32::MAX).is_some());
 }
diff --git a/src/test/ui/issues/issue-8460-const.rs b/src/test/ui/issues/issue-8460-const.rs
index c18a0d4d6cbbe..220de51b9b9a0 100644
--- a/src/test/ui/issues/issue-8460-const.rs
+++ b/src/test/ui/issues/issue-8460-const.rs
@@ -3,7 +3,6 @@
 
 #![deny(const_err)]
 
-use std::{isize, i8, i16, i32, i64};
 use std::thread;
 
 fn main() {
diff --git a/src/test/ui/issues/issue-8460-const2.rs b/src/test/ui/issues/issue-8460-const2.rs
index 0ca850abc1b60..9716bbf9845b7 100644
--- a/src/test/ui/issues/issue-8460-const2.rs
+++ b/src/test/ui/issues/issue-8460-const2.rs
@@ -3,7 +3,6 @@
 
 #![deny(const_err)]
 
-use std::{isize, i8, i16, i32, i64};
 use std::thread;
 
 fn main() {
diff --git a/src/test/ui/iterators/iter-count-overflow-debug.rs b/src/test/ui/iterators/iter-count-overflow-debug.rs
index d661203575083..f5feb8d7640af 100644
--- a/src/test/ui/iterators/iter-count-overflow-debug.rs
+++ b/src/test/ui/iterators/iter-count-overflow-debug.rs
@@ -4,13 +4,12 @@
 // compile-flags: -C debug_assertions=yes -C opt-level=3
 
 use std::panic;
-use std::usize::MAX;
 
 fn main() {
-    assert_eq!((0..MAX).by_ref().count(), MAX);
+    assert_eq!((0..usize::MAX).by_ref().count(), MAX);
 
     let r = panic::catch_unwind(|| {
-        (0..=MAX).by_ref().count()
+        (0..=usize::MAX).by_ref().count()
     });
     assert!(r.is_err());
 }
diff --git a/src/test/ui/iterators/iter-count-overflow-ndebug.rs b/src/test/ui/iterators/iter-count-overflow-ndebug.rs
index b755bb554f441..2ecf5096bf819 100644
--- a/src/test/ui/iterators/iter-count-overflow-ndebug.rs
+++ b/src/test/ui/iterators/iter-count-overflow-ndebug.rs
@@ -3,9 +3,8 @@
 // compile-flags: -C debug_assertions=no -C opt-level=3
 
 use std::panic;
-use std::usize::MAX;
 
 fn main() {
-    assert_eq!((0..MAX).by_ref().count(), MAX);
-    assert_eq!((0..=MAX).by_ref().count(), 0);
+    assert_eq!((0..usize::MAX).by_ref().count(), usize::MAX);
+    assert_eq!((0..=usize::MAX).by_ref().count(), 0);
 }
diff --git a/src/test/ui/iterators/iter-position-overflow-debug.rs b/src/test/ui/iterators/iter-position-overflow-debug.rs
index f1eded31702c4..733ee0c46cc3d 100644
--- a/src/test/ui/iterators/iter-position-overflow-debug.rs
+++ b/src/test/ui/iterators/iter-position-overflow-debug.rs
@@ -4,11 +4,10 @@
 // compile-flags: -C debug_assertions=yes -C opt-level=3
 
 use std::panic;
-use std::usize::MAX;
 
 fn main() {
-    let n = MAX as u64;
-    assert_eq!((0..).by_ref().position(|i| i >= n), Some(MAX));
+    let n = usize::MAX as u64;
+    assert_eq!((0..).by_ref().position(|i| i >= n), Some(usize::MAX));
 
     let r = panic::catch_unwind(|| {
         (0..).by_ref().position(|i| i > n)
diff --git a/src/test/ui/iterators/iter-position-overflow-ndebug.rs b/src/test/ui/iterators/iter-position-overflow-ndebug.rs
index 368f9c0c02b07..d4532ee8f59e8 100644
--- a/src/test/ui/iterators/iter-position-overflow-ndebug.rs
+++ b/src/test/ui/iterators/iter-position-overflow-ndebug.rs
@@ -3,11 +3,10 @@
 // compile-flags: -C debug_assertions=no -C opt-level=3
 
 use std::panic;
-use std::usize::MAX;
 
 fn main() {
-    let n = MAX as u64;
-    assert_eq!((0..).by_ref().position(|i| i >= n), Some(MAX));
+    let n = usize::MAX as u64;
+    assert_eq!((0..).by_ref().position(|i| i >= n), Some(usize::MAX));
     assert_eq!((0..).by_ref().position(|i| i > n), Some(0));
     assert_eq!((0..=n + 1).by_ref().position(|_| false), None);
 }
diff --git a/src/test/ui/macros/macro-first-set.rs b/src/test/ui/macros/macro-first-set.rs
index eb2504d4bfdb7..b5484b9ce9107 100644
--- a/src/test/ui/macros/macro-first-set.rs
+++ b/src/test/ui/macros/macro-first-set.rs
@@ -249,7 +249,7 @@ macro_rules! test_path {
 test_path!();
 test_path!(,);
 test_path!(::std);
-test_path!(std::u8,);
+test_path!(u8,);
 test_path!(any, super, super::super::self::path, X<Y>::Z<'a, T=U>);
 
 macro_rules! test_lifetime {
diff --git a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs
index 5fcd3392d33e3..52a5103865123 100644
--- a/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs
+++ b/src/test/ui/moves/moves-based-on-type-move-out-of-closure-env-issue-1965.rs
@@ -1,7 +1,5 @@
 #![feature(box_syntax, unboxed_closures)]
 
-use std::usize;
-
 fn to_fn<A,F:Fn<A>>(f: F) -> F { f }
 
 fn test(_x: Box<usize>) {}
diff --git a/src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs b/src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs
index e9927304f23f8..101c5d50b20b9 100644
--- a/src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs
+++ b/src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs
@@ -9,12 +9,12 @@ fn main() {
     macro_rules! overflow_test {
         ($t:ident) => (
             let r = panic::catch_unwind(|| {
-                ($t::max_value()).next_power_of_two()
+                ($t::MAX).next_power_of_two()
             });
             assert!(r.is_err());
 
             let r = panic::catch_unwind(|| {
-                (($t::max_value() >> 1) + 2).next_power_of_two()
+                (($t::MAX >> 1) + 2).next_power_of_two()
             });
             assert!(r.is_err());
         )
diff --git a/src/test/ui/numbers-arithmetic/saturating-float-casts.rs b/src/test/ui/numbers-arithmetic/saturating-float-casts.rs
index f13964fb38665..22081adcf61ff 100644
--- a/src/test/ui/numbers-arithmetic/saturating-float-casts.rs
+++ b/src/test/ui/numbers-arithmetic/saturating-float-casts.rs
@@ -7,9 +7,6 @@
 extern crate test;
 
 use std::{f32, f64};
-use std::{u8, i8, u16, i16, u32, i32, u64, i64};
-#[cfg(not(target_os="emscripten"))]
-use std::{u128, i128};
 use test::black_box;
 
 macro_rules! test {
diff --git a/src/test/ui/numbers-arithmetic/shift-near-oflo.rs b/src/test/ui/numbers-arithmetic/shift-near-oflo.rs
index 939eb9746121f..55006a1134297 100644
--- a/src/test/ui/numbers-arithmetic/shift-near-oflo.rs
+++ b/src/test/ui/numbers-arithmetic/shift-near-oflo.rs
@@ -47,21 +47,21 @@ fn test_left_shift() {
     let x = 1_u8 << id(0);
     assert_eq!(x, 1);
     let x = 1_i8 << id(7);
-    assert_eq!(x, std::i8::MIN);
+    assert_eq!(x, i8::MIN);
     let x = 1_u8 << id(7);
     assert_eq!(x, 0x80);
     // high-order bits on LHS are silently discarded without panic.
     let x = 3_i8 << id(7);
-    assert_eq!(x, std::i8::MIN);
+    assert_eq!(x, i8::MIN);
     let x = 3_u8 << id(7);
     assert_eq!(x, 0x80);
 
     // above is (approximately) expanded from:
-    tests!(i8, u8, 7, std::i8::MIN, 0x80_u8);
+    tests!(i8, u8, 7, i8::MIN, 0x80_u8);
 
-    tests!(i16, u16, 15, std::i16::MIN, 0x8000_u16);
-    tests!(i32, u32, 31, std::i32::MIN, 0x8000_0000_u32);
-    tests!(i64, u64, 63, std::i64::MIN, 0x8000_0000_0000_0000_u64);
+    tests!(i16, u16, 15, i16::MIN, 0x8000_u16);
+    tests!(i32, u32, 31, i32::MIN, 0x8000_0000_u32);
+    tests!(i64, u64, 63, i64::MIN, 0x8000_0000_0000_0000_u64);
 }
 
 fn test_right_shift() {
@@ -92,9 +92,9 @@ fn test_right_shift() {
         } }
     }
 
-    tests!(i8, u8, 7, std::i8::MIN, 0x40_i8, 0x80_u8);
-    tests!(i16, u16, 15, std::i16::MIN, 0x4000_u16, 0x8000_u16);
-    tests!(i32, u32, 31, std::i32::MIN, 0x4000_0000_u32, 0x8000_0000_u32);
-    tests!(i64, u64, 63, std::i64::MIN,
+    tests!(i8, u8, 7, i8::MIN, 0x40_i8, 0x80_u8);
+    tests!(i16, u16, 15, i16::MIN, 0x4000_u16, 0x8000_u16);
+    tests!(i32, u32, 31, i32::MIN, 0x4000_0000_u32, 0x8000_0000_u32);
+    tests!(i64, u64, 63, i64::MIN,
            0x4000_0000_0000_0000_u64, 0x8000_0000_0000_0000_u64);
 }
diff --git a/src/test/ui/numbers-arithmetic/u128-as-f32.rs b/src/test/ui/numbers-arithmetic/u128-as-f32.rs
index 2671a267f4a87..433cf2c116161 100644
--- a/src/test/ui/numbers-arithmetic/u128-as-f32.rs
+++ b/src/test/ui/numbers-arithmetic/u128-as-f32.rs
@@ -5,7 +5,6 @@
 extern crate test;
 
 use std::f32;
-use std::u128;
 use test::black_box;
 
 macro_rules! test {
diff --git a/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs b/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs
index d7c191bb5a28d..29bb6c9af00b7 100644
--- a/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs
+++ b/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.rs
@@ -12,15 +12,15 @@ fn main() {
     }
 
     match (0u8, 0u8) {
-        //~^ ERROR non-exhaustive patterns: `(2u8..=std::u8::MAX, _)`
+        //~^ ERROR non-exhaustive patterns: `(2u8..=u8::MAX, _)`
         (0 | 1, 2 | 3) => {}
     }
     match ((0u8,),) {
-        //~^ ERROR non-exhaustive patterns: `((4u8..=std::u8::MAX))`
+        //~^ ERROR non-exhaustive patterns: `((4u8..=u8::MAX))`
         ((0 | 1,) | (2 | 3,),) => {},
     }
     match (Some(0u8),) {
-        //~^ ERROR non-exhaustive patterns: `(Some(2u8..=std::u8::MAX))`
+        //~^ ERROR non-exhaustive patterns: `(Some(2u8..=u8::MAX))`
         (None | Some(0 | 1),) => {}
     }
 }
diff --git a/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr b/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr
index e6aa157d278c8..8a4205a0c7cbd 100644
--- a/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr
+++ b/src/test/ui/or-patterns/exhaustiveness-non-exhaustive.stderr
@@ -1,24 +1,24 @@
-error[E0004]: non-exhaustive patterns: `(2u8..=std::u8::MAX, _)` not covered
+error[E0004]: non-exhaustive patterns: `(2u8..=u8::MAX, _)` not covered
   --> $DIR/exhaustiveness-non-exhaustive.rs:14:11
    |
 LL |     match (0u8, 0u8) {
-   |           ^^^^^^^^^^ pattern `(2u8..=std::u8::MAX, _)` not covered
+   |           ^^^^^^^^^^ pattern `(2u8..=u8::MAX, _)` not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
-error[E0004]: non-exhaustive patterns: `((4u8..=std::u8::MAX))` not covered
+error[E0004]: non-exhaustive patterns: `((4u8..=u8::MAX))` not covered
   --> $DIR/exhaustiveness-non-exhaustive.rs:18:11
    |
 LL |     match ((0u8,),) {
-   |           ^^^^^^^^^ pattern `((4u8..=std::u8::MAX))` not covered
+   |           ^^^^^^^^^ pattern `((4u8..=u8::MAX))` not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
-error[E0004]: non-exhaustive patterns: `(Some(2u8..=std::u8::MAX))` not covered
+error[E0004]: non-exhaustive patterns: `(Some(2u8..=u8::MAX))` not covered
   --> $DIR/exhaustiveness-non-exhaustive.rs:22:11
    |
 LL |     match (Some(0u8),) {
-   |           ^^^^^^^^^^^^ pattern `(Some(2u8..=std::u8::MAX))` not covered
+   |           ^^^^^^^^^^^^ pattern `(Some(2u8..=u8::MAX))` not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
diff --git a/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.rs b/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.rs
index d379dc44bf10b..76de68489d6df 100644
--- a/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.rs
+++ b/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.rs
@@ -3,7 +3,7 @@
 #![deny(unreachable_patterns)]
 #![deny(overlapping_patterns)]
 
-use std::{char, u8, u16, u32, u64, u128, i8, i16, i32, i64, i128};
+use std::char;
 
 fn main() {
     let x: u8 = 0;
diff --git a/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.stderr b/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.stderr
index 0fbeb981ea015..878aa5977eb27 100644
--- a/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.stderr
+++ b/src/test/ui/pattern/usefulness/exhaustive_integer_patterns.stderr
@@ -10,11 +10,11 @@ note: lint level defined here
 LL | #![deny(unreachable_patterns)]
    |         ^^^^^^^^^^^^^^^^^^^^
 
-error[E0004]: non-exhaustive patterns: `128u8..=std::u8::MAX` not covered
+error[E0004]: non-exhaustive patterns: `128u8..=u8::MAX` not covered
   --> $DIR/exhaustive_integer_patterns.rs:28:11
    |
 LL |     match x {
-   |           ^ pattern `128u8..=std::u8::MAX` not covered
+   |           ^ pattern `128u8..=u8::MAX` not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
@@ -32,19 +32,19 @@ error: unreachable pattern
 LL |         -2..=20 => {}
    |         ^^^^^^^
 
-error[E0004]: non-exhaustive patterns: `std::i8::MIN..=-8i8`, `-6i8`, `121i8..=124i8` and 1 more not covered
+error[E0004]: non-exhaustive patterns: `i8::MIN..=-8i8`, `-6i8`, `121i8..=124i8` and 1 more not covered
   --> $DIR/exhaustive_integer_patterns.rs:41:11
    |
 LL |     match x {
-   |           ^ patterns `std::i8::MIN..=-8i8`, `-6i8`, `121i8..=124i8` and 1 more not covered
+   |           ^ patterns `i8::MIN..=-8i8`, `-6i8`, `121i8..=124i8` and 1 more not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
-error[E0004]: non-exhaustive patterns: `std::i8::MIN` not covered
+error[E0004]: non-exhaustive patterns: `i8::MIN` not covered
   --> $DIR/exhaustive_integer_patterns.rs:83:11
    |
 LL |     match 0i8 {
-   |           ^^^ pattern `std::i8::MIN` not covered
+   |           ^^^ pattern `i8::MIN` not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
@@ -56,19 +56,19 @@ LL |     match 0i16 {
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
-error[E0004]: non-exhaustive patterns: `128u8..=std::u8::MAX` not covered
+error[E0004]: non-exhaustive patterns: `128u8..=u8::MAX` not covered
   --> $DIR/exhaustive_integer_patterns.rs:109:11
    |
 LL |     match 0u8 {
-   |           ^^^ pattern `128u8..=std::u8::MAX` not covered
+   |           ^^^ pattern `128u8..=u8::MAX` not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
-error[E0004]: non-exhaustive patterns: `(0u8, Some(_))` and `(2u8..=std::u8::MAX, Some(_))` not covered
+error[E0004]: non-exhaustive patterns: `(0u8, Some(_))` and `(2u8..=u8::MAX, Some(_))` not covered
   --> $DIR/exhaustive_integer_patterns.rs:121:11
    |
 LL |     match (0u8, Some(())) {
-   |           ^^^^^^^^^^^^^^^ patterns `(0u8, Some(_))` and `(2u8..=std::u8::MAX, Some(_))` not covered
+   |           ^^^^^^^^^^^^^^^ patterns `(0u8, Some(_))` and `(2u8..=u8::MAX, Some(_))` not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
@@ -94,19 +94,19 @@ note: lint level defined here
 LL | #![deny(overlapping_patterns)]
    |         ^^^^^^^^^^^^^^^^^^^^
 
-error[E0004]: non-exhaustive patterns: `std::u128::MAX` not covered
+error[E0004]: non-exhaustive patterns: `u128::MAX` not covered
   --> $DIR/exhaustive_integer_patterns.rs:146:11
    |
 LL |     match 0u128 {
-   |           ^^^^^ pattern `std::u128::MAX` not covered
+   |           ^^^^^ pattern `u128::MAX` not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
-error[E0004]: non-exhaustive patterns: `5u128..=std::u128::MAX` not covered
+error[E0004]: non-exhaustive patterns: `5u128..=u128::MAX` not covered
   --> $DIR/exhaustive_integer_patterns.rs:150:11
    |
 LL |     match 0u128 {
-   |           ^^^^^ pattern `5u128..=std::u128::MAX` not covered
+   |           ^^^^^ pattern `5u128..=u128::MAX` not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
diff --git a/src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr b/src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr
index 539aa854f9e6b..7d24c8a39ff6d 100644
--- a/src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr
+++ b/src/test/ui/pattern/usefulness/match-byte-array-patterns-2.stderr
@@ -1,8 +1,8 @@
-error[E0004]: non-exhaustive patterns: `&[0u8..=64u8, _, _, _]` and `&[66u8..=std::u8::MAX, _, _, _]` not covered
+error[E0004]: non-exhaustive patterns: `&[0u8..=64u8, _, _, _]` and `&[66u8..=u8::MAX, _, _, _]` not covered
   --> $DIR/match-byte-array-patterns-2.rs:4:11
    |
 LL |     match buf {
-   |           ^^^ patterns `&[0u8..=64u8, _, _, _]` and `&[66u8..=std::u8::MAX, _, _, _]` not covered
+   |           ^^^ patterns `&[0u8..=64u8, _, _, _]` and `&[66u8..=u8::MAX, _, _, _]` not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
diff --git a/src/test/ui/pattern/usefulness/match-non-exhaustive.stderr b/src/test/ui/pattern/usefulness/match-non-exhaustive.stderr
index 211f333882b10..c52a2e532b2b7 100644
--- a/src/test/ui/pattern/usefulness/match-non-exhaustive.stderr
+++ b/src/test/ui/pattern/usefulness/match-non-exhaustive.stderr
@@ -1,8 +1,8 @@
-error[E0004]: non-exhaustive patterns: `std::i32::MIN..=0i32` and `2i32..=std::i32::MAX` not covered
+error[E0004]: non-exhaustive patterns: `i32::MIN..=0i32` and `2i32..=i32::MAX` not covered
   --> $DIR/match-non-exhaustive.rs:2:11
    |
 LL |     match 0 { 1 => () }
-   |           ^ patterns `std::i32::MIN..=0i32` and `2i32..=std::i32::MAX` not covered
+   |           ^ patterns `i32::MIN..=0i32` and `2i32..=i32::MAX` not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
diff --git a/src/test/ui/pattern/usefulness/non-exhaustive-match.rs b/src/test/ui/pattern/usefulness/non-exhaustive-match.rs
index bfca5352353a7..695c14227de5d 100644
--- a/src/test/ui/pattern/usefulness/non-exhaustive-match.rs
+++ b/src/test/ui/pattern/usefulness/non-exhaustive-match.rs
@@ -12,8 +12,8 @@ fn main() {
     match Some(10) { //~ ERROR non-exhaustive patterns: `Some(_)` not covered
       None => {}
     }
-    match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, std::i32::MIN..=3i32)`
-                      //  and `(_, _, 5i32..=std::i32::MAX)` not covered
+    match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, i32::MIN..=3i32)`
+                      //  and `(_, _, 5i32..=i32::MAX)` not covered
       (_, _, 4) => {}
     }
     match (T::A, T::A) { //~ ERROR non-exhaustive patterns: `(A, A)` not covered
diff --git a/src/test/ui/pattern/usefulness/non-exhaustive-match.stderr b/src/test/ui/pattern/usefulness/non-exhaustive-match.stderr
index 577867e4e7122..ddf01b235ad67 100644
--- a/src/test/ui/pattern/usefulness/non-exhaustive-match.stderr
+++ b/src/test/ui/pattern/usefulness/non-exhaustive-match.stderr
@@ -28,11 +28,11 @@ LL |     match Some(10) {
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
-error[E0004]: non-exhaustive patterns: `(_, _, std::i32::MIN..=3i32)` and `(_, _, 5i32..=std::i32::MAX)` not covered
+error[E0004]: non-exhaustive patterns: `(_, _, i32::MIN..=3i32)` and `(_, _, 5i32..=i32::MAX)` not covered
   --> $DIR/non-exhaustive-match.rs:15:11
    |
 LL |     match (2, 3, 4) {
-   |           ^^^^^^^^^ patterns `(_, _, std::i32::MIN..=3i32)` and `(_, _, 5i32..=std::i32::MAX)` not covered
+   |           ^^^^^^^^^ patterns `(_, _, i32::MIN..=3i32)` and `(_, _, 5i32..=i32::MAX)` not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
diff --git a/src/test/ui/pattern/usefulness/refutable-pattern-errors.rs b/src/test/ui/pattern/usefulness/refutable-pattern-errors.rs
index d4afe17ca748c..3ef2ead32cb7c 100644
--- a/src/test/ui/pattern/usefulness/refutable-pattern-errors.rs
+++ b/src/test/ui/pattern/usefulness/refutable-pattern-errors.rs
@@ -5,5 +5,5 @@ fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) { }
 
 fn main() {
     let (1, (Some(1), 2..=3)) = (1, (None, 2));
-    //~^ ERROR refutable pattern in local binding: `(std::i32::MIN..=0i32, _)` and `(2i32..=std::i32::MAX, _)` not covered
+    //~^ ERROR refutable pattern in local binding: `(i32::MIN..=0i32, _)` and `(2i32..=i32::MAX, _)` not covered
 }
diff --git a/src/test/ui/pattern/usefulness/refutable-pattern-errors.stderr b/src/test/ui/pattern/usefulness/refutable-pattern-errors.stderr
index 0cf5d9cd5f12a..0ba01a0b002d5 100644
--- a/src/test/ui/pattern/usefulness/refutable-pattern-errors.stderr
+++ b/src/test/ui/pattern/usefulness/refutable-pattern-errors.stderr
@@ -4,11 +4,11 @@ error[E0005]: refutable pattern in function argument: `(_, _)` not covered
 LL | fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) { }
    |         ^^^^^^^^^^^^^^^^^^^^^ pattern `(_, _)` not covered
 
-error[E0005]: refutable pattern in local binding: `(std::i32::MIN..=0i32, _)` and `(2i32..=std::i32::MAX, _)` not covered
+error[E0005]: refutable pattern in local binding: `(i32::MIN..=0i32, _)` and `(2i32..=i32::MAX, _)` not covered
   --> $DIR/refutable-pattern-errors.rs:7:9
    |
 LL |     let (1, (Some(1), 2..=3)) = (1, (None, 2));
-   |         ^^^^^^^^^^^^^^^^^^^^^ patterns `(std::i32::MIN..=0i32, _)` and `(2i32..=std::i32::MAX, _)` not covered
+   |         ^^^^^^^^^^^^^^^^^^^^^ patterns `(i32::MIN..=0i32, _)` and `(2i32..=i32::MAX, _)` not covered
    |
    = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
    = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
diff --git a/src/test/ui/precise_pointer_size_matching.rs b/src/test/ui/precise_pointer_size_matching.rs
index 54aeb8616d959..4b40eb5bcfe68 100644
--- a/src/test/ui/precise_pointer_size_matching.rs
+++ b/src/test/ui/precise_pointer_size_matching.rs
@@ -10,8 +10,6 @@
 
 #![deny(unreachable_patterns, overlapping_patterns)]
 
-use std::{usize, isize};
-
 fn main() {
     match 0isize {
         isize::MIN ..= isize::MAX => {} // ok
diff --git a/src/test/ui/precise_pointer_size_matching.stderr b/src/test/ui/precise_pointer_size_matching.stderr
index 2c2c2aa04c233..402c30dfca1f8 100644
--- a/src/test/ui/precise_pointer_size_matching.stderr
+++ b/src/test/ui/precise_pointer_size_matching.stderr
@@ -1,16 +1,16 @@
-error[E0004]: non-exhaustive patterns: `std::isize::MIN..=-6isize` and `21isize..=std::isize::MAX` not covered
+error[E0004]: non-exhaustive patterns: `isize::MIN..=-6isize` and `21isize..=isize::MAX` not covered
   --> $DIR/precise_pointer_size_matching.rs:24:11
    |
 LL |     match 0isize {
-   |           ^^^^^^ patterns `std::isize::MIN..=-6isize` and `21isize..=std::isize::MAX` not covered
+   |           ^^^^^^ patterns `isize::MIN..=-6isize` and `21isize..=isize::MAX` not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
-error[E0004]: non-exhaustive patterns: `0usize` and `21usize..=std::usize::MAX` not covered
+error[E0004]: non-exhaustive patterns: `0usize` and `21usize..=usize::MAX` not covered
   --> $DIR/precise_pointer_size_matching.rs:29:11
    |
 LL |     match 0usize {
-   |           ^^^^^^ patterns `0usize` and `21usize..=std::usize::MAX` not covered
+   |           ^^^^^^ patterns `0usize` and `21usize..=usize::MAX` not covered
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 
diff --git a/src/test/ui/regions/regions-addr-of-upvar-self.rs b/src/test/ui/regions/regions-addr-of-upvar-self.rs
index 1f8fe9a4439b9..6159ab02d3d95 100644
--- a/src/test/ui/regions/regions-addr-of-upvar-self.rs
+++ b/src/test/ui/regions/regions-addr-of-upvar-self.rs
@@ -1,5 +1,3 @@
-use std::usize;
-
 struct Dog {
     food: usize,
 }
diff --git a/src/test/ui/rfc-2627-raw-dylib/link-ordinal-too-large.stderr b/src/test/ui/rfc-2627-raw-dylib/link-ordinal-too-large.stderr
index b3b22f9776df7..b9b877aa0566c 100644
--- a/src/test/ui/rfc-2627-raw-dylib/link-ordinal-too-large.stderr
+++ b/src/test/ui/rfc-2627-raw-dylib/link-ordinal-too-large.stderr
@@ -12,7 +12,7 @@ error: ordinal value in `link_ordinal` is too large: `18446744073709551616`
 LL |     #[link_ordinal(18446744073709551616)]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: the value may not exceed `std::usize::MAX`
+   = note: the value may not exceed `usize::MAX`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/sleep.rs b/src/test/ui/sleep.rs
index 757578b84750c..3713d301ed8a2 100644
--- a/src/test/ui/sleep.rs
+++ b/src/test/ui/sleep.rs
@@ -5,7 +5,6 @@
 use std::thread::{self, sleep};
 use std::time::Duration;
 use std::sync::{Arc, Mutex};
-use std::u64;
 
 fn main() {
     let finished = Arc::new(Mutex::new(false));
diff --git a/src/test/ui/structs-enums/discrim-explicit-23030.rs b/src/test/ui/structs-enums/discrim-explicit-23030.rs
index 211ca7e4e8feb..af7ab865e3222 100644
--- a/src/test/ui/structs-enums/discrim-explicit-23030.rs
+++ b/src/test/ui/structs-enums/discrim-explicit-23030.rs
@@ -5,8 +5,6 @@
 // See also compile-fail/overflow-discrim.rs, which shows what
 // happens if you leave the OhNo explicit cases out here.
 
-use std::{i8,u8,i16,u16,i32,u32,i64,u64,isize,usize};
-
 fn f_i8() {
     #[repr(i8)]
     enum A {
diff --git a/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.rs b/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.rs
index 2a11871db8e67..21fb8d4a2e68d 100644
--- a/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.rs
+++ b/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.rs
@@ -1,6 +1,6 @@
 fn main() {
     let A = 3;
-    //~^ ERROR refutable pattern in local binding: `std::i32::MIN..=1i32` and
+    //~^ ERROR refutable pattern in local binding: `i32::MIN..=1i32` and
     //~| interpreted as a constant pattern, not a new variable
     //~| HELP introduce a variable instead
     //~| SUGGESTION a_var
diff --git a/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr b/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr
index fc17199bf91d4..5aa01c6c41428 100644
--- a/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr
+++ b/src/test/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr
@@ -1,4 +1,4 @@
-error[E0005]: refutable pattern in local binding: `std::i32::MIN..=1i32` and `3i32..=std::i32::MAX` not covered
+error[E0005]: refutable pattern in local binding: `i32::MIN..=1i32` and `3i32..=i32::MAX` not covered
   --> $DIR/const-pat-non-exaustive-let-new-var.rs:2:9
    |
 LL |     let A = 3;
diff --git a/src/test/ui/wrapping-int-api.rs b/src/test/ui/wrapping-int-api.rs
index ecdd742fb4e08..6e2fc7f80b9c4 100644
--- a/src/test/ui/wrapping-int-api.rs
+++ b/src/test/ui/wrapping-int-api.rs
@@ -4,9 +4,6 @@
 // Don't warn about overflowing ops on 32-bit platforms
 #![cfg_attr(target_pointer_width = "32", allow(const_err))]
 
-use std::{i8, i16, i32, i64, isize};
-use std::{u8, u16, u32, u64, usize};
-
 fn main() {
     assert_eq!(   i8::MAX.wrapping_add(1),    i8::MIN);
     assert_eq!(  i16::MAX.wrapping_add(1),   i16::MIN);
diff --git a/src/test/ui/wrapping-int-combinations.rs b/src/test/ui/wrapping-int-combinations.rs
index f0bc479ee0ff2..a9f4000009b7c 100644
--- a/src/test/ui/wrapping-int-combinations.rs
+++ b/src/test/ui/wrapping-int-combinations.rs
@@ -60,18 +60,18 @@ macro_rules! wrapping_test {
 }
 
 fn main() {
-    wrapping_test!(i8, std::i8::MIN, std::i8::MAX);
-    wrapping_test!(i16, std::i16::MIN, std::i16::MAX);
-    wrapping_test!(i32, std::i32::MIN, std::i32::MAX);
-    wrapping_test!(i64, std::i64::MIN, std::i64::MAX);
+    wrapping_test!(i8, i8::MIN, i8::MAX);
+    wrapping_test!(i16, i16::MIN, i16::MAX);
+    wrapping_test!(i32, i32::MIN, i32::MAX);
+    wrapping_test!(i64, i64::MIN, i64::MAX);
     #[cfg(not(target_os = "emscripten"))]
-    wrapping_test!(i128, std::i128::MIN, std::i128::MAX);
-    wrapping_test!(isize, std::isize::MIN, std::isize::MAX);
-    wrapping_test!(u8, std::u8::MIN, std::u8::MAX);
-    wrapping_test!(u16, std::u16::MIN, std::u16::MAX);
-    wrapping_test!(u32, std::u32::MIN, std::u32::MAX);
-    wrapping_test!(u64, std::u64::MIN, std::u64::MAX);
+    wrapping_test!(i128, i128::MIN, i128::MAX);
+    wrapping_test!(isize, isize::MIN, isize::MAX);
+    wrapping_test!(u8, u8::MIN, u8::MAX);
+    wrapping_test!(u16, u16::MIN, u16::MAX);
+    wrapping_test!(u32, u32::MIN, u32::MAX);
+    wrapping_test!(u64, u64::MIN, u64::MAX);
     #[cfg(not(target_os = "emscripten"))]
-    wrapping_test!(u128, std::u128::MIN, std::u128::MAX);
-    wrapping_test!(usize, std::usize::MIN, std::usize::MAX);
+    wrapping_test!(u128, u128::MIN, u128::MAX);
+    wrapping_test!(usize, usize::MIN, usize::MAX);
 }

From 57ad77b2290a38e2629aa1a1e22199f259d8809c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= <faern@faern.net>
Date: Wed, 18 Dec 2019 00:19:30 +0100
Subject: [PATCH 08/15] Add associated constants on floats, deprecate same
 module level consts

---
 src/libcore/num/f32.rs | 96 ++++++++++++++++++++++++++++++++++++------
 src/libcore/num/f64.rs | 95 +++++++++++++++++++++++++++++++++++------
 2 files changed, 163 insertions(+), 28 deletions(-)

diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs
index 505484c2a49dc..51d6770437cb2 100644
--- a/src/libcore/num/f32.rs
+++ b/src/libcore/num/f32.rs
@@ -15,14 +15,17 @@ use crate::num::FpCategory;
 
 /// The radix or base of the internal representation of `f32`.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const RADIX: u32 = 2;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const RADIX: u32 = f32::RADIX;
 
 /// Number of significant digits in base 2.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MANTISSA_DIGITS: u32 = 24;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const MANTISSA_DIGITS: u32 = f32::MANTISSA_DIGITS;
 /// Approximate number of significant digits in base 10.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const DIGITS: u32 = 6;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const DIGITS: u32 = f32::DIGITS;
 
 /// [Machine epsilon] value for `f32`.
 ///
@@ -30,41 +33,52 @@ pub const DIGITS: u32 = 6;
 ///
 /// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const EPSILON: f32 = 1.1920929e-7_f32;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const EPSILON: f32 = f32::EPSILON;
 
 /// Smallest finite `f32` value.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MIN: f32 = -3.40282347e+38_f32;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const MIN: f32 = f32::MIN;
 /// Smallest positive normal `f32` value.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MIN_POSITIVE: f32 = 1.17549435e-38_f32;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const MIN_POSITIVE: f32 = f32::MIN_POSITIVE;
 /// Largest finite `f32` value.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MAX: f32 = 3.40282347e+38_f32;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const MAX: f32 = f32::MAX;
 
 /// One greater than the minimum possible normal power of 2 exponent.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MIN_EXP: i32 = -125;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const MIN_EXP: i32 = f32::MIN_EXP;
 /// Maximum possible power of 2 exponent.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MAX_EXP: i32 = 128;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const MAX_EXP: i32 = f32::MAX_EXP;
 
 /// Minimum possible normal power of 10 exponent.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MIN_10_EXP: i32 = -37;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const MIN_10_EXP: i32 = f32::MIN_10_EXP;
 /// Maximum possible power of 10 exponent.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MAX_10_EXP: i32 = 38;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const MAX_10_EXP: i32 = f32::MAX_10_EXP;
 
 /// Not a Number (NaN).
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const NAN: f32 = 0.0_f32 / 0.0_f32;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const NAN: f32 = f32::NAN;
 /// Infinity (∞).
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const INFINITY: f32 = 1.0_f32 / 0.0_f32;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const INFINITY: f32 = f32::INFINITY;
 /// Negative infinity (−∞).
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const NEG_INFINITY: f32 = -1.0_f32 / 0.0_f32;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const NEG_INFINITY: f32 = f32::NEG_INFINITY;
 
 /// Basic mathematical constants.
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -153,6 +167,60 @@ pub mod consts {
 #[lang = "f32"]
 #[cfg(not(test))]
 impl f32 {
+    /// The radix or base of the internal representation of `f32`.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const RADIX: u32 = 2;
+
+    /// Number of significant digits in base 2.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const MANTISSA_DIGITS: u32 = 24;
+
+    /// Approximate number of significant digits in base 10.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const DIGITS: u32 = 6;
+
+    /// [Machine epsilon] value for `f32`.
+    ///
+    /// This is the difference between `1.0` and the next larger representable number.
+    ///
+    /// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const EPSILON: f32 = 1.19209290e-07_f32;
+
+    /// Smallest finite `f32` value.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const MIN: f32 = -3.40282347e+38_f32;
+    /// Smallest positive normal `f32` value.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const MIN_POSITIVE: f32 = 1.17549435e-38_f32;
+    /// Largest finite `f32` value.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const MAX: f32 = 3.40282347e+38_f32;
+
+    /// One greater than the minimum possible normal power of 2 exponent.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const MIN_EXP: i32 = -125;
+    /// Maximum possible power of 2 exponent.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const MAX_EXP: i32 = 128;
+
+    /// Minimum possible normal power of 10 exponent.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const MIN_10_EXP: i32 = -37;
+    /// Maximum possible power of 10 exponent.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const MAX_10_EXP: i32 = 38;
+
+    /// Not a Number (NaN).
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const NAN: f32 = 0.0_f32 / 0.0_f32;
+    /// Infinity (∞).
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const INFINITY: f32 = 1.0_f32 / 0.0_f32;
+    /// Negative infinity (-∞).
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const NEG_INFINITY: f32 = -1.0_f32 / 0.0_f32;
+
     /// Returns `true` if this value is `NaN`.
     ///
     /// ```
diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs
index 8f3af42d25d80..21172fd75ddfe 100644
--- a/src/libcore/num/f64.rs
+++ b/src/libcore/num/f64.rs
@@ -15,14 +15,17 @@ use crate::num::FpCategory;
 
 /// The radix or base of the internal representation of `f64`.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const RADIX: u32 = 2;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const RADIX: u32 = f64::RADIX;
 
 /// Number of significant digits in base 2.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MANTISSA_DIGITS: u32 = 53;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const MANTISSA_DIGITS: u32 = f64::MANTISSA_DIGITS;
 /// Approximate number of significant digits in base 10.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const DIGITS: u32 = 15;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const DIGITS: u32 = f64::DIGITS;
 
 /// [Machine epsilon] value for `f64`.
 ///
@@ -30,41 +33,52 @@ pub const DIGITS: u32 = 15;
 ///
 /// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const EPSILON: f64 = 2.2204460492503131e-16_f64;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const EPSILON: f64 = f64::EPSILON;
 
 /// Smallest finite `f64` value.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MIN: f64 = -1.7976931348623157e+308_f64;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const MIN: f64 = f64::MIN;
 /// Smallest positive normal `f64` value.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MIN_POSITIVE: f64 = 2.2250738585072014e-308_f64;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const MIN_POSITIVE: f64 = f64::MIN_POSITIVE;
 /// Largest finite `f64` value.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MAX: f64 = 1.7976931348623157e+308_f64;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const MAX: f64 = f64::MAX;
 
 /// One greater than the minimum possible normal power of 2 exponent.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MIN_EXP: i32 = -1021;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const MIN_EXP: i32 = f64::MIN_EXP;
 /// Maximum possible power of 2 exponent.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MAX_EXP: i32 = 1024;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const MAX_EXP: i32 = f64::MAX_EXP;
 
 /// Minimum possible normal power of 10 exponent.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MIN_10_EXP: i32 = -307;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const MIN_10_EXP: i32 = f64::MIN_10_EXP;
 /// Maximum possible power of 10 exponent.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MAX_10_EXP: i32 = 308;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const MAX_10_EXP: i32 = f64::MAX_10_EXP;
 
 /// Not a Number (NaN).
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const NAN: f64 = 0.0_f64 / 0.0_f64;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const NAN: f64 = f64::NAN;
 /// Infinity (∞).
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const INFINITY: f64 = f64::INFINITY;
 /// Negative infinity (−∞).
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
+#[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant")]
+pub const NEG_INFINITY: f64 = f64::NEG_INFINITY;
 
 /// Basic mathematical constants.
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -153,6 +167,59 @@ pub mod consts {
 #[lang = "f64"]
 #[cfg(not(test))]
 impl f64 {
+    /// The radix or base of the internal representation of `f64`.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const RADIX: u32 = 2;
+
+    /// Number of significant digits in base 2.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const MANTISSA_DIGITS: u32 = 53;
+    /// Approximate number of significant digits in base 10.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const DIGITS: u32 = 15;
+
+    /// [Machine epsilon] value for `f64`.
+    ///
+    /// This is the difference between `1.0` and the next larger representable number.
+    ///
+    /// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const EPSILON: f64 = 2.2204460492503131e-16_f64;
+
+    /// Smallest finite `f64` value.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const MIN: f64 = -1.7976931348623157e+308_f64;
+    /// Smallest positive normal `f64` value.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const MIN_POSITIVE: f64 = 2.2250738585072014e-308_f64;
+    /// Largest finite `f64` value.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const MAX: f64 = 1.7976931348623157e+308_f64;
+
+    /// One greater than the minimum possible normal power of 2 exponent.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const MIN_EXP: i32 = -1021;
+    /// Maximum possible power of 2 exponent.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const MAX_EXP: i32 = 1024;
+
+    /// Minimum possible normal power of 10 exponent.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const MIN_10_EXP: i32 = -307;
+    /// Maximum possible power of 10 exponent.
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const MAX_10_EXP: i32 = 308;
+
+    /// Not a Number (NaN).
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const NAN: f64 = 0.0_f64 / 0.0_f64;
+    /// Infinity (∞).
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const INFINITY: f64 = 1.0_f64 / 0.0_f64;
+    /// Negative infinity (-∞).
+    #[stable(feature = "assoc_int_consts", since = "1.42.0")]
+    pub const NEG_INFINITY: f64 = -1.0_f64 / 0.0_f64;
+
     /// Returns `true` if this value is `NaN`.
     ///
     /// ```

From 252c5f4e43c4a03fac3cd869c90dee60eafd8aa3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= <faern@faern.net>
Date: Wed, 18 Dec 2019 00:26:22 +0100
Subject: [PATCH 09/15] Use float associated constants

---
 src/liballoc/tests.rs                         |  1 -
 src/libcore/num/dec2flt/rawfp.rs              | 10 +--
 src/libcore/num/f32.rs                        |  4 +-
 src/libcore/num/f64.rs                        |  4 +-
 src/libcore/num/flt2dec/decoder.rs            |  1 -
 src/libcore/tests/iter.rs                     |  1 -
 src/libcore/tests/num/mod.rs                  |  2 -
 src/libcore/tests/ops.rs                      | 18 +++--
 src/libserialize/json.rs                      |  2 +-
 src/libstd/f32.rs                             | 42 +++++-------
 src/libstd/f64.rs                             | 68 +++++++++----------
 src/test/ui/format-nan.rs                     |  1 -
 src/test/ui/issues/issue-50811.rs             |  9 ++-
 src/test/ui/issues/issue-6804.rs              |  8 +--
 .../float-int-invalid-const-cast.rs           |  2 -
 src/test/ui/numbers-arithmetic/float-nan.rs   |  1 -
 .../saturating-float-casts.rs                 |  1 -
 src/test/ui/numbers-arithmetic/u128-as-f32.rs |  1 -
 .../ui/rfc1445/match-forbidden-without-eq.rs  |  2 -
 .../ui/simd/simd-intrinsic-float-minmax.rs    |  4 +-
 .../simd/simd-intrinsic-generic-comparison.rs |  4 +-
 src/test/ui/union/union-transmute.rs          |  1 -
 22 files changed, 78 insertions(+), 109 deletions(-)

diff --git a/src/liballoc/tests.rs b/src/liballoc/tests.rs
index 21ab5c003ec57..bddaab0c76188 100644
--- a/src/liballoc/tests.rs
+++ b/src/liballoc/tests.rs
@@ -3,7 +3,6 @@
 use core::any::Any;
 use core::clone::Clone;
 use core::convert::TryInto;
-use core::f64;
 use core::ops::Deref;
 use core::result::Result::{Err, Ok};
 
diff --git a/src/libcore/num/dec2flt/rawfp.rs b/src/libcore/num/dec2flt/rawfp.rs
index a127c6c3fa7ce..0ab15b23e5337 100644
--- a/src/libcore/num/dec2flt/rawfp.rs
+++ b/src/libcore/num/dec2flt/rawfp.rs
@@ -129,15 +129,15 @@ macro_rules! other_constants {
     ($type: ident) => {
         const EXPLICIT_SIG_BITS: u8 = Self::SIG_BITS - 1;
         const MAX_EXP: i16 = (1 << (Self::EXP_BITS - 1)) - 1;
-        const MIN_EXP: i16 = -Self::MAX_EXP + 1;
-        const MAX_EXP_INT: i16 = Self::MAX_EXP - (Self::SIG_BITS as i16 - 1);
+        const MIN_EXP: i16 = -<Self as RawFloat>::MAX_EXP + 1;
+        const MAX_EXP_INT: i16 = <Self as RawFloat>::MAX_EXP - (Self::SIG_BITS as i16 - 1);
         const MAX_ENCODED_EXP: i16 = (1 << Self::EXP_BITS) - 1;
-        const MIN_EXP_INT: i16 = Self::MIN_EXP - (Self::SIG_BITS as i16 - 1);
+        const MIN_EXP_INT: i16 = <Self as RawFloat>::MIN_EXP - (Self::SIG_BITS as i16 - 1);
         const MAX_SIG: u64 = (1 << Self::SIG_BITS) - 1;
         const MIN_SIG: u64 = 1 << (Self::SIG_BITS - 1);
 
-        const INFINITY: Self = $crate::$type::INFINITY;
-        const NAN: Self = $crate::$type::NAN;
+        const INFINITY: Self = $type::INFINITY;
+        const NAN: Self = $type::NAN;
         const ZERO: Self = 0.0;
     };
 }
diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs
index 51d6770437cb2..ca03b7a2b0604 100644
--- a/src/libcore/num/f32.rs
+++ b/src/libcore/num/f32.rs
@@ -266,7 +266,7 @@ impl f32 {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
     pub fn is_infinite(self) -> bool {
-        self.abs_private() == INFINITY
+        self.abs_private() == Self::INFINITY
     }
 
     /// Returns `true` if this number is neither infinite nor `NaN`.
@@ -290,7 +290,7 @@ impl f32 {
     pub fn is_finite(self) -> bool {
         // There's no need to handle NaN separately: if self is NaN,
         // the comparison is not true, exactly as desired.
-        self.abs_private() < INFINITY
+        self.abs_private() < Self::INFINITY
     }
 
     /// Returns `true` if the number is neither zero, infinite,
diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs
index 21172fd75ddfe..cc9f0bb9a0961 100644
--- a/src/libcore/num/f64.rs
+++ b/src/libcore/num/f64.rs
@@ -265,7 +265,7 @@ impl f64 {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
     pub fn is_infinite(self) -> bool {
-        self.abs_private() == INFINITY
+        self.abs_private() == Self::INFINITY
     }
 
     /// Returns `true` if this number is neither infinite nor `NaN`.
@@ -289,7 +289,7 @@ impl f64 {
     pub fn is_finite(self) -> bool {
         // There's no need to handle NaN separately: if self is NaN,
         // the comparison is not true, exactly as desired.
-        self.abs_private() < INFINITY
+        self.abs_private() < Self::INFINITY
     }
 
     /// Returns `true` if the number is neither zero, infinite,
diff --git a/src/libcore/num/flt2dec/decoder.rs b/src/libcore/num/flt2dec/decoder.rs
index 2b74effbe2e98..c43536c6fcca8 100644
--- a/src/libcore/num/flt2dec/decoder.rs
+++ b/src/libcore/num/flt2dec/decoder.rs
@@ -2,7 +2,6 @@
 
 use crate::num::dec2flt::rawfp::RawFloat;
 use crate::num::FpCategory;
-use crate::{f32, f64};
 
 /// Decoded unsigned finite value, such that:
 ///
diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs
index 815d06baf96c6..8cb399b9ea408 100644
--- a/src/libcore/tests/iter.rs
+++ b/src/libcore/tests/iter.rs
@@ -74,7 +74,6 @@ fn test_cmp_by() {
 #[test]
 fn test_partial_cmp_by() {
     use core::cmp::Ordering;
-    use core::f64;
 
     let f = |x: i32, y: i32| (x * x).partial_cmp(&y);
     let xs = || [1, 2, 3, 4].iter().copied();
diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs
index 981ced34a809c..e7ee674cde67e 100644
--- a/src/libcore/tests/num/mod.rs
+++ b/src/libcore/tests/num/mod.rs
@@ -205,8 +205,6 @@ test_impl_from! { test_u32f64, u32, f64 }
 // Float -> Float
 #[test]
 fn test_f32f64() {
-    use core::f32;
-
     let max: f64 = f32::MAX.into();
     assert_eq!(max as f32, f32::MAX);
     assert!(max.is_normal());
diff --git a/src/libcore/tests/ops.rs b/src/libcore/tests/ops.rs
index 43eb498d26ab1..3c83f0f230003 100644
--- a/src/libcore/tests/ops.rs
+++ b/src/libcore/tests/ops.rs
@@ -61,25 +61,23 @@ fn test_range_inclusive() {
 
 #[test]
 fn test_range_is_empty() {
-    use core::f32::*;
-
     assert!(!(0.0..10.0).is_empty());
     assert!((-0.0..0.0).is_empty());
     assert!((10.0..0.0).is_empty());
 
-    assert!(!(NEG_INFINITY..INFINITY).is_empty());
-    assert!((EPSILON..NAN).is_empty());
-    assert!((NAN..EPSILON).is_empty());
-    assert!((NAN..NAN).is_empty());
+    assert!(!(f32::NEG_INFINITY..f32::INFINITY).is_empty());
+    assert!((f32::EPSILON..f32::NAN).is_empty());
+    assert!((f32::NAN..f32::EPSILON).is_empty());
+    assert!((f32::NAN..f32::NAN).is_empty());
 
     assert!(!(0.0..=10.0).is_empty());
     assert!(!(-0.0..=0.0).is_empty());
     assert!((10.0..=0.0).is_empty());
 
-    assert!(!(NEG_INFINITY..=INFINITY).is_empty());
-    assert!((EPSILON..=NAN).is_empty());
-    assert!((NAN..=EPSILON).is_empty());
-    assert!((NAN..=NAN).is_empty());
+    assert!(!(f32::NEG_INFINITY..=f32::INFINITY).is_empty());
+    assert!((f32::EPSILON..=f32::NAN).is_empty());
+    assert!((f32::NAN..=f32::EPSILON).is_empty());
+    assert!((f32::NAN..=f32::NAN).is_empty());
 }
 
 #[test]
diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs
index 1f9d43cb93043..cacc28b6e60e4 100644
--- a/src/libserialize/json.rs
+++ b/src/libserialize/json.rs
@@ -198,7 +198,7 @@ use std::num::FpCategory as Fp;
 use std::ops::Index;
 use std::str::FromStr;
 use std::string;
-use std::{char, f64, fmt, str};
+use std::{char, fmt, str};
 
 use crate::Encodable;
 
diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs
index 267d7013b1e42..f3a57c571256f 100644
--- a/src/libstd/f32.rs
+++ b/src/libstd/f32.rs
@@ -16,12 +16,20 @@ use crate::sys::cmath;
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use core::f32::consts;
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::f32::{DIGITS, EPSILON, MANTISSA_DIGITS, RADIX};
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::f32::{INFINITY, MAX_10_EXP, NAN, NEG_INFINITY};
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::f32::{MAX, MIN, MIN_POSITIVE};
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::f32::{MAX_EXP, MIN_10_EXP, MIN_EXP};
 
 #[cfg(not(test))]
@@ -181,8 +189,6 @@ impl f32 {
     /// # Examples
     ///
     /// ```
-    /// use std::f32;
-    ///
     /// let f = 3.5_f32;
     ///
     /// assert_eq!(f.signum(), 1.0);
@@ -194,7 +200,7 @@ impl f32 {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
     pub fn signum(self) -> f32 {
-        if self.is_nan() { NAN } else { 1.0_f32.copysign(self) }
+        if self.is_nan() { Self::NAN } else { 1.0_f32.copysign(self) }
     }
 
     /// Returns a number composed of the magnitude of `self` and the sign of
@@ -207,8 +213,6 @@ impl f32 {
     /// # Examples
     ///
     /// ```
-    /// use std::f32;
-    ///
     /// let f = 3.5_f32;
     ///
     /// assert_eq!(f.copysign(0.42), 3.5_f32);
@@ -234,8 +238,6 @@ impl f32 {
     /// # Examples
     ///
     /// ```
-    /// use std::f32;
-    ///
     /// let m = 10.0_f32;
     /// let x = 4.0_f32;
     /// let b = 60.0_f32;
@@ -362,8 +364,6 @@ impl f32 {
     /// # Examples
     ///
     /// ```
-    /// use std::f32;
-    ///
     /// let positive = 4.0_f32;
     /// let negative = -4.0_f32;
     ///
@@ -898,8 +898,6 @@ impl f32 {
     /// # Examples
     ///
     /// ```
-    /// use std::f32;
-    ///
     /// let e = f32::consts::E;
     /// let x = 1.0f32;
     ///
@@ -922,8 +920,6 @@ impl f32 {
     /// # Examples
     ///
     /// ```
-    /// use std::f32;
-    ///
     /// let x = 1.0f32;
     /// let f = x.sinh().asinh();
     ///
@@ -935,8 +931,8 @@ impl f32 {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
     pub fn asinh(self) -> f32 {
-        if self == NEG_INFINITY {
-            NEG_INFINITY
+        if self == Self::NEG_INFINITY {
+            Self::NEG_INFINITY
         } else {
             (self + ((self * self) + 1.0).sqrt()).ln().copysign(self)
         }
@@ -947,8 +943,6 @@ impl f32 {
     /// # Examples
     ///
     /// ```
-    /// use std::f32;
-    ///
     /// let x = 1.0f32;
     /// let f = x.cosh().acosh();
     ///
@@ -960,7 +954,7 @@ impl f32 {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
     pub fn acosh(self) -> f32 {
-        if self < 1.0 { crate::f32::NAN } else { (self + ((self * self) - 1.0).sqrt()).ln() }
+        if self < 1.0 { Self::NAN } else { (self + ((self * self) - 1.0).sqrt()).ln() }
     }
 
     /// Inverse hyperbolic tangent function.
@@ -968,8 +962,6 @@ impl f32 {
     /// # Examples
     ///
     /// ```
-    /// use std::f32;
-    ///
     /// let e = f32::consts::E;
     /// let f = e.tanh().atanh();
     ///
@@ -1023,8 +1015,6 @@ impl f32 {
 
 #[cfg(test)]
 mod tests {
-    use crate::f32;
-    use crate::f32::*;
     use crate::num::FpCategory as Fp;
     use crate::num::*;
 
@@ -1035,14 +1025,14 @@ mod tests {
 
     #[test]
     fn test_min_nan() {
-        assert_eq!(NAN.min(2.0), 2.0);
-        assert_eq!(2.0f32.min(NAN), 2.0);
+        assert_eq!(f32::NAN.min(2.0), 2.0);
+        assert_eq!(2.0f32.min(f32::NAN), 2.0);
     }
 
     #[test]
     fn test_max_nan() {
-        assert_eq!(NAN.max(2.0), 2.0);
-        assert_eq!(2.0f32.max(NAN), 2.0);
+        assert_eq!(f32::NAN.max(2.0), 2.0);
+        assert_eq!(2.0f32.max(f32::NAN), 2.0);
     }
 
     #[test]
diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs
index 61ce7b29e26fc..ccd8a632cc9c8 100644
--- a/src/libstd/f64.rs
+++ b/src/libstd/f64.rs
@@ -16,12 +16,20 @@ use crate::sys::cmath;
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use core::f64::consts;
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::f64::{DIGITS, EPSILON, MANTISSA_DIGITS, RADIX};
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::f64::{INFINITY, MAX_10_EXP, NAN, NEG_INFINITY};
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::f64::{MAX, MIN, MIN_POSITIVE};
 #[stable(feature = "rust1", since = "1.0.0")]
+#[allow(deprecated_in_future)]
+#[allow(deprecated)]
 pub use core::f64::{MAX_EXP, MIN_10_EXP, MIN_EXP};
 
 #[cfg(not(test))]
@@ -159,8 +167,6 @@ impl f64 {
     /// # Examples
     ///
     /// ```
-    /// use std::f64;
-    ///
     /// let f = 3.5_f64;
     ///
     /// assert_eq!(f.signum(), 1.0);
@@ -172,7 +178,7 @@ impl f64 {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
     pub fn signum(self) -> f64 {
-        if self.is_nan() { NAN } else { 1.0_f64.copysign(self) }
+        if self.is_nan() { Self::NAN } else { 1.0_f64.copysign(self) }
     }
 
     /// Returns a number composed of the magnitude of `self` and the sign of
@@ -185,8 +191,6 @@ impl f64 {
     /// # Examples
     ///
     /// ```
-    /// use std::f64;
-    ///
     /// let f = 3.5_f64;
     ///
     /// assert_eq!(f.copysign(0.42), 3.5_f64);
@@ -859,8 +863,8 @@ impl f64 {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
     pub fn asinh(self) -> f64 {
-        if self == NEG_INFINITY {
-            NEG_INFINITY
+        if self == Self::NEG_INFINITY {
+            Self::NEG_INFINITY
         } else {
             (self + ((self * self) + 1.0).sqrt()).ln().copysign(self)
         }
@@ -882,7 +886,7 @@ impl f64 {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
     pub fn acosh(self) -> f64 {
-        if self < 1.0 { NAN } else { (self + ((self * self) - 1.0).sqrt()).ln() }
+        if self < 1.0 { Self::NAN } else { (self + ((self * self) - 1.0).sqrt()).ln() }
     }
 
     /// Inverse hyperbolic tangent function.
@@ -890,8 +894,6 @@ impl f64 {
     /// # Examples
     ///
     /// ```
-    /// use std::f64;
-    ///
     /// let e = f64::consts::E;
     /// let f = e.tanh().atanh();
     ///
@@ -953,16 +955,16 @@ impl f64 {
                 if self > 0.0 {
                     log_fn(self)
                 } else if self == 0.0 {
-                    NEG_INFINITY // log(0) = -Inf
+                    Self::NEG_INFINITY // log(0) = -Inf
                 } else {
-                    NAN // log(-n) = NaN
+                    Self::NAN // log(-n) = NaN
                 }
             } else if self.is_nan() {
                 self // log(NaN) = NaN
             } else if self > 0.0 {
                 self // log(Inf) = Inf
             } else {
-                NAN // log(-Inf) = NaN
+                Self::NAN // log(-Inf) = NaN
             }
         }
     }
@@ -970,8 +972,6 @@ impl f64 {
 
 #[cfg(test)]
 mod tests {
-    use crate::f64;
-    use crate::f64::*;
     use crate::num::FpCategory as Fp;
     use crate::num::*;
 
@@ -982,19 +982,19 @@ mod tests {
 
     #[test]
     fn test_min_nan() {
-        assert_eq!(NAN.min(2.0), 2.0);
-        assert_eq!(2.0f64.min(NAN), 2.0);
+        assert_eq!(f64::NAN.min(2.0), 2.0);
+        assert_eq!(2.0f64.min(f64::NAN), 2.0);
     }
 
     #[test]
     fn test_max_nan() {
-        assert_eq!(NAN.max(2.0), 2.0);
-        assert_eq!(2.0f64.max(NAN), 2.0);
+        assert_eq!(f64::NAN.max(2.0), 2.0);
+        assert_eq!(2.0f64.max(f64::NAN), 2.0);
     }
 
     #[test]
     fn test_nan() {
-        let nan: f64 = NAN;
+        let nan: f64 = f64::NAN;
         assert!(nan.is_nan());
         assert!(!nan.is_infinite());
         assert!(!nan.is_finite());
@@ -1006,7 +1006,7 @@ mod tests {
 
     #[test]
     fn test_infinity() {
-        let inf: f64 = INFINITY;
+        let inf: f64 = f64::INFINITY;
         assert!(inf.is_infinite());
         assert!(!inf.is_finite());
         assert!(inf.is_sign_positive());
@@ -1018,7 +1018,7 @@ mod tests {
 
     #[test]
     fn test_neg_infinity() {
-        let neg_inf: f64 = NEG_INFINITY;
+        let neg_inf: f64 = f64::NEG_INFINITY;
         assert!(neg_inf.is_infinite());
         assert!(!neg_inf.is_finite());
         assert!(!neg_inf.is_sign_positive());
@@ -1070,9 +1070,9 @@ mod tests {
 
     #[test]
     fn test_is_nan() {
-        let nan: f64 = NAN;
-        let inf: f64 = INFINITY;
-        let neg_inf: f64 = NEG_INFINITY;
+        let nan: f64 = f64::NAN;
+        let inf: f64 = f64::INFINITY;
+        let neg_inf: f64 = f64::NEG_INFINITY;
         assert!(nan.is_nan());
         assert!(!0.0f64.is_nan());
         assert!(!5.3f64.is_nan());
@@ -1083,9 +1083,9 @@ mod tests {
 
     #[test]
     fn test_is_infinite() {
-        let nan: f64 = NAN;
-        let inf: f64 = INFINITY;
-        let neg_inf: f64 = NEG_INFINITY;
+        let nan: f64 = f64::NAN;
+        let inf: f64 = f64::INFINITY;
+        let neg_inf: f64 = f64::NEG_INFINITY;
         assert!(!nan.is_infinite());
         assert!(inf.is_infinite());
         assert!(neg_inf.is_infinite());
@@ -1110,9 +1110,9 @@ mod tests {
     #[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630
     #[test]
     fn test_is_normal() {
-        let nan: f64 = NAN;
-        let inf: f64 = INFINITY;
-        let neg_inf: f64 = NEG_INFINITY;
+        let nan: f64 = f64::NAN;
+        let inf: f64 = f64::INFINITY;
+        let neg_inf: f64 = f64::NEG_INFINITY;
         let zero: f64 = 0.0f64;
         let neg_zero: f64 = -0.0;
         assert!(!nan.is_normal());
@@ -1128,9 +1128,9 @@ mod tests {
     #[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630
     #[test]
     fn test_classify() {
-        let nan: f64 = NAN;
-        let inf: f64 = INFINITY;
-        let neg_inf: f64 = NEG_INFINITY;
+        let nan: f64 = f64::NAN;
+        let inf: f64 = f64::INFINITY;
+        let neg_inf: f64 = f64::NEG_INFINITY;
         let zero: f64 = 0.0f64;
         let neg_zero: f64 = -0.0;
         assert_eq!(nan.classify(), Fp::Nan);
diff --git a/src/test/ui/format-nan.rs b/src/test/ui/format-nan.rs
index e4a134fa2fbe0..438f3f46036f7 100644
--- a/src/test/ui/format-nan.rs
+++ b/src/test/ui/format-nan.rs
@@ -1,7 +1,6 @@
 // run-pass
 
 pub fn main() {
-    use std::f64;
     let x = "NaN".to_string();
     assert_eq!(format!("{}", f64::NAN), x);
     assert_eq!(format!("{:e}", f64::NAN), x);
diff --git a/src/test/ui/issues/issue-50811.rs b/src/test/ui/issues/issue-50811.rs
index 63d87e03c4899..683c856049fdc 100644
--- a/src/test/ui/issues/issue-50811.rs
+++ b/src/test/ui/issues/issue-50811.rs
@@ -3,7 +3,6 @@
 
 extern crate test;
 
-use std::f64::{NAN, NEG_INFINITY, INFINITY, MAX};
 use std::mem::size_of;
 use test::black_box;
 
@@ -12,7 +11,7 @@ use test::black_box;
 macro_rules! compare {
     ($op:tt) => {
         compare!(
-            [NEG_INFINITY, -MAX, -1.0, -0.0, 0.0, 1.0, MAX, INFINITY, NAN],
+            [f64::NEG_INFINITY, -f64::MAX, -1.0, -0.0, 0.0, 1.0, f64::MAX, f64::INFINITY, f64::NAN],
             $op
         );
     };
@@ -20,7 +19,7 @@ macro_rules! compare {
         $(compare!(
             $lhs,
             $op,
-            [NEG_INFINITY, -MAX, -1.0, -0.0, 0.0, 1.0, MAX, INFINITY, NAN]
+            [f64::NEG_INFINITY, -f64::MAX, -1.0, -0.0, 0.0, 1.0, f64::MAX, f64::INFINITY, f64::NAN]
         );)+
     };
     ($lhs:expr, $op:tt, [$($rhs:expr),+]) => {
@@ -44,8 +43,8 @@ macro_rules! compare {
 fn main() {
     assert_eq!(0.0/0.0 < 0.0/0.0, false);
     assert_eq!(0.0/0.0 > 0.0/0.0, false);
-    assert_eq!(NAN < NAN, false);
-    assert_eq!(NAN > NAN, false);
+    assert_eq!(f64::NAN < f64::NAN, false);
+    assert_eq!(f64::NAN > f64::NAN, false);
 
     compare!(==);
     compare!(!=);
diff --git a/src/test/ui/issues/issue-6804.rs b/src/test/ui/issues/issue-6804.rs
index b4af3581a0de0..36b14d7555dd2 100644
--- a/src/test/ui/issues/issue-6804.rs
+++ b/src/test/ui/issues/issue-6804.rs
@@ -3,12 +3,10 @@
 #![allow(unused)]
 #![deny(illegal_floating_point_literal_pattern)]
 
-use std::f64::NAN;
-
 fn main() {
-    let x = NAN;
+    let x = f64::NAN;
     match x {
-        NAN => {}, //~ ERROR floating-point types cannot be used
+        f64::NAN => {}, //~ ERROR floating-point types cannot be used
         //~^ WARN this was previously accepted by the compiler but is being phased out
         //~| ERROR floating-point types cannot be used in patterns
         //~| WARN this was previously accepted by the compiler but is being phased out
@@ -16,7 +14,7 @@ fn main() {
     };
 
     match [x, 1.0] {
-        [NAN, _] => {}, //~ ERROR floating-point types cannot be used
+        [f64::NAN, _] => {}, //~ ERROR floating-point types cannot be used
         //~^ WARN this was previously accepted by the compiler but is being phased out
         _ => {},
     };
diff --git a/src/test/ui/numbers-arithmetic/float-int-invalid-const-cast.rs b/src/test/ui/numbers-arithmetic/float-int-invalid-const-cast.rs
index ced3c61ec162a..7691149602bc6 100644
--- a/src/test/ui/numbers-arithmetic/float-int-invalid-const-cast.rs
+++ b/src/test/ui/numbers-arithmetic/float-int-invalid-const-cast.rs
@@ -2,8 +2,6 @@
 
 #![deny(const_err)]
 
-use std::{f32, f64};
-
 // Forces evaluation of constants, triggering hard error
 fn force<T>(_: T) {}
 
diff --git a/src/test/ui/numbers-arithmetic/float-nan.rs b/src/test/ui/numbers-arithmetic/float-nan.rs
index ee87b8cccfe40..0cc6473e5c48c 100644
--- a/src/test/ui/numbers-arithmetic/float-nan.rs
+++ b/src/test/ui/numbers-arithmetic/float-nan.rs
@@ -1,5 +1,4 @@
 // run-pass
-use std::f64;
 
 pub fn main() {
   let nan: f64 = f64::NAN;
diff --git a/src/test/ui/numbers-arithmetic/saturating-float-casts.rs b/src/test/ui/numbers-arithmetic/saturating-float-casts.rs
index 22081adcf61ff..76c75ffb029dd 100644
--- a/src/test/ui/numbers-arithmetic/saturating-float-casts.rs
+++ b/src/test/ui/numbers-arithmetic/saturating-float-casts.rs
@@ -6,7 +6,6 @@
 #![deny(overflowing_literals)]
 extern crate test;
 
-use std::{f32, f64};
 use test::black_box;
 
 macro_rules! test {
diff --git a/src/test/ui/numbers-arithmetic/u128-as-f32.rs b/src/test/ui/numbers-arithmetic/u128-as-f32.rs
index 433cf2c116161..839ce932d9e76 100644
--- a/src/test/ui/numbers-arithmetic/u128-as-f32.rs
+++ b/src/test/ui/numbers-arithmetic/u128-as-f32.rs
@@ -4,7 +4,6 @@
 #![deny(overflowing_literals)]
 extern crate test;
 
-use std::f32;
 use test::black_box;
 
 macro_rules! test {
diff --git a/src/test/ui/rfc1445/match-forbidden-without-eq.rs b/src/test/ui/rfc1445/match-forbidden-without-eq.rs
index 1cca27520618d..fa5630837b9ad 100644
--- a/src/test/ui/rfc1445/match-forbidden-without-eq.rs
+++ b/src/test/ui/rfc1445/match-forbidden-without-eq.rs
@@ -1,5 +1,3 @@
-use std::f32;
-
 #[derive(PartialEq)]
 struct Foo {
     x: u32
diff --git a/src/test/ui/simd/simd-intrinsic-float-minmax.rs b/src/test/ui/simd/simd-intrinsic-float-minmax.rs
index 5f0aa11af5fb8..d79be61f90995 100644
--- a/src/test/ui/simd/simd-intrinsic-float-minmax.rs
+++ b/src/test/ui/simd/simd-intrinsic-float-minmax.rs
@@ -20,11 +20,11 @@ fn main() {
     let y = f32x4(2.0, 1.0, 4.0, 3.0);
 
     #[cfg(not(any(target_arch = "mips", target_arch = "mips64")))]
-    let nan = ::std::f32::NAN;
+    let nan = f32::NAN;
     // MIPS hardware treats f32::NAN as SNAN. Clear the signaling bit.
     // See https://github.com/rust-lang/rust/issues/52746.
     #[cfg(any(target_arch = "mips", target_arch = "mips64"))]
-    let nan = f32::from_bits(::std::f32::NAN.to_bits() - 1);
+    let nan = f32::from_bits(f32::NAN.to_bits() - 1);
 
     let n = f32x4(nan, nan, nan, nan);
 
diff --git a/src/test/ui/simd/simd-intrinsic-generic-comparison.rs b/src/test/ui/simd/simd-intrinsic-generic-comparison.rs
index 2b593e1c9b804..103132c18ae2f 100644
--- a/src/test/ui/simd/simd-intrinsic-generic-comparison.rs
+++ b/src/test/ui/simd/simd-intrinsic-generic-comparison.rs
@@ -4,8 +4,6 @@
 #![feature(repr_simd, platform_intrinsics, concat_idents)]
 #![allow(non_camel_case_types)]
 
-use std::f32::NAN;
-
 #[repr(simd)]
 #[derive(Copy, Clone)]
 struct i32x4(i32, i32, i32, i32);
@@ -94,7 +92,7 @@ fn main() {
     // NAN comparisons are special:
     // -11 (*)    13
     // -5        -100 (*)
-    let f4 = f32x4(NAN, f1.1, NAN, f2.3);
+    let f4 = f32x4(f32::NAN, f1.1, f32::NAN, f2.3);
 
     unsafe {
         tests! {
diff --git a/src/test/ui/union/union-transmute.rs b/src/test/ui/union/union-transmute.rs
index ac7dede98a3a3..2f739953895a1 100644
--- a/src/test/ui/union/union-transmute.rs
+++ b/src/test/ui/union/union-transmute.rs
@@ -1,7 +1,6 @@
 // run-pass
 
 extern crate core;
-use core::f32;
 
 union U {
     a: (u8, u8),

From e6e7694b4ad8cf164f2ace8386b2e6b17fe06f22 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= <faern@faern.net>
Date: Wed, 18 Dec 2019 11:09:44 +0100
Subject: [PATCH 10/15] TMP (can be improved): Don't import integer modules

---
 src/test/ui/numbers-arithmetic/num-wrapping.rs | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/test/ui/numbers-arithmetic/num-wrapping.rs b/src/test/ui/numbers-arithmetic/num-wrapping.rs
index 9a01549ecd24e..860c830fb5d0d 100644
--- a/src/test/ui/numbers-arithmetic/num-wrapping.rs
+++ b/src/test/ui/numbers-arithmetic/num-wrapping.rs
@@ -21,7 +21,6 @@ macro_rules! int_modules {
     ($(($name:ident, $size:expr),)*) => ($(
         mod $name {
             pub const BITS: usize = $size;
-            pub use std::$name::*;
         }
     )*)
 }

From 5a5c90422ae98d1999401b44aeda960fe4c1f5e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= <faern@faern.net>
Date: Wed, 18 Dec 2019 11:32:18 +0100
Subject: [PATCH 11/15] Allow deprecated in test specifically for primitive vs
 module fallback

---
 src/test/ui/issues/issue-20427.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/test/ui/issues/issue-20427.rs b/src/test/ui/issues/issue-20427.rs
index fa2ea6cf592af..21c5a73054acc 100644
--- a/src/test/ui/issues/issue-20427.rs
+++ b/src/test/ui/issues/issue-20427.rs
@@ -66,6 +66,7 @@ mod reuse {
 }
 
 mod guard {
+    #[allow(deprecated)]
     pub fn check() {
         use std::u8; // bring module u8 in scope
         fn f() -> u8 { // OK, resolves to primitive u8, not to std::u8

From 32cfeefdd54e04a79ea533b71ce352f94beba304 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= <faern@faern.net>
Date: Mon, 6 Jan 2020 02:32:16 +0100
Subject: [PATCH 12/15] up to 42 on num/mod

---
 src/libcore/num/mod.rs | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 3294ecfc25a66..162f4ab7c8811 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -255,7 +255,7 @@ Basic usage:
 ", $Feature, "assert_eq!(", stringify!($SelfT), "::MIN, ", stringify!($Min), ");",
 $EndFeature, "
 ```"),
-            #[stable(feature = "assoc_int_consts", since = "1.41.0")]
+            #[stable(feature = "assoc_int_consts", since = "1.42.0")]
             pub const MIN: Self = !0 ^ ((!0 as $UnsignedT) >> 1) as Self;
         }
 
@@ -270,14 +270,14 @@ Basic usage:
 ", $Feature, "assert_eq!(", stringify!($SelfT), "::MAX, ", stringify!($Max), ");",
 $EndFeature, "
 ```"),
-            #[stable(feature = "assoc_int_consts", since = "1.41.0")]
+            #[stable(feature = "assoc_int_consts", since = "1.42.0")]
             pub const MAX: Self = !Self::MIN;
         }
 
         doc_comment! {
             "Returns the smallest value that can be represented by this integer type.",
             #[stable(feature = "rust1", since = "1.0.0")]
-            #[rustc_deprecated(since = "1.41.0", reason = "replaced by associated constant MIN")]
+            #[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant MIN")]
             #[inline(always)]
             #[rustc_promotable]
             #[rustc_const_stable(feature = "const_min_value", since = "1.32.0")]
@@ -289,7 +289,7 @@ $EndFeature, "
         doc_comment! {
             "Returns the largest value that can be represented by this integer type.",
             #[stable(feature = "rust1", since = "1.0.0")]
-            #[rustc_deprecated(since = "1.41.0", reason = "replaced by associated constant MAX")]
+            #[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant MAX")]
             #[inline(always)]
             #[rustc_promotable]
             #[rustc_const_stable(feature = "const_max_value", since = "1.32.0")]
@@ -2362,7 +2362,7 @@ Basic usage:
 ```
 ", $Feature, "assert_eq!(", stringify!($SelfT), "::MIN, 0);", $EndFeature, "
 ```"),
-            #[stable(feature = "assoc_int_consts", since = "1.41.0")]
+            #[stable(feature = "assoc_int_consts", since = "1.42.0")]
             pub const MIN: Self = 0;
         }
 
@@ -2377,14 +2377,14 @@ Basic usage:
 ", $Feature, "assert_eq!(", stringify!($SelfT), "::MAX, ", stringify!($MaxV), ");",
 $EndFeature, "
 ```"),
-            #[stable(feature = "assoc_int_consts", since = "1.41.0")]
+            #[stable(feature = "assoc_int_consts", since = "1.42.0")]
             pub const MAX: Self = !0;
         }
 
         doc_comment! {
             "Returns the smallest value that can be represented by this integer type.",
             #[stable(feature = "rust1", since = "1.0.0")]
-            #[rustc_deprecated(since = "1.41.0", reason = "replaced by associated constant MIN")]
+            #[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant MIN")]
             #[rustc_promotable]
             #[inline(always)]
             #[rustc_const_stable(feature = "const_max_value", since = "1.32.0")]
@@ -2394,7 +2394,7 @@ $EndFeature, "
         doc_comment! {
             "Returns the largest value that can be represented by this integer type.",
             #[stable(feature = "rust1", since = "1.0.0")]
-            #[rustc_deprecated(since = "1.41.0", reason = "replaced by associated constant MAX")]
+            #[rustc_deprecated(since = "1.42.0", reason = "replaced by associated constant MAX")]
             #[rustc_promotable]
             #[inline(always)]
             #[rustc_const_stable(feature = "const_max_value", since = "1.32.0")]

From b3546c594719462cbadaf483a6ded2a83b0d6971 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= <faern@faern.net>
Date: Mon, 6 Jan 2020 15:11:57 +0100
Subject: [PATCH 13/15] Remove invalid import

Co-Authored-By: lzutao <taolzu@gmail.com>
---
 src/libstd/collections/hash/map.rs | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index bafcc7f5b16d6..a42621ca01cf1 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -2619,7 +2619,6 @@ mod test_map {
     use crate::cell::RefCell;
     use rand::{thread_rng, Rng};
     use realstd::collections::TryReserveError::*;
-    use realusize;
 
     // https://github.com/rust-lang/rust/issues/62301
     fn _assert_hashmap_is_unwind_safe() {

From c73af28172b2fa258ecccbbf05df77bbadf6f04a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= <faern@faern.net>
Date: Mon, 6 Jan 2020 15:15:09 +0100
Subject: [PATCH 14/15] Remove superfluous <> around usize

Co-Authored-By: lzutao <taolzu@gmail.com>
---
 src/libstd/io/cursor.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs
index 960cca89a104c..ccc4f9d5f899a 100644
--- a/src/libstd/io/cursor.rs
+++ b/src/libstd/io/cursor.rs
@@ -939,7 +939,7 @@ mod tests {
     #[cfg(target_pointer_width = "32")]
     fn vec_seek_and_write_past_usize_max() {
         let mut c = Cursor::new(Vec::new());
-        c.set_position(<usize>::MAX as u64 + 1);
+        c.set_position(usize::MAX as u64 + 1);
         assert!(c.write_all(&[1, 2, 3]).is_err());
     }
 

From ab389e5ed8e1b0389fc1ce86e168d6e145b65cdb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= <faern@faern.net>
Date: Mon, 6 Jan 2020 16:21:45 +0100
Subject: [PATCH 15/15] Use cmp::min instead of manual if-else

Co-Authored-By: lzutao <taolzu@gmail.com>
---
 src/libstd/sys/unix/condvar.rs    | 2 +-
 src/libstd/sys/vxworks/condvar.rs | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/libstd/sys/unix/condvar.rs b/src/libstd/sys/unix/condvar.rs
index 9f1847943f326..a27d1ce83c4b7 100644
--- a/src/libstd/sys/unix/condvar.rs
+++ b/src/libstd/sys/unix/condvar.rs
@@ -13,7 +13,7 @@ const TIMESPEC_MAX: libc::timespec =
     libc::timespec { tv_sec: <libc::time_t>::MAX, tv_nsec: 1_000_000_000 - 1 };
 
 fn saturating_cast_to_time_t(value: u64) -> libc::time_t {
-    if value > <libc::time_t>::MAX as u64 { <libc::time_t>::MAX } else { value as libc::time_t }
+    crate::cmp::min(value, libc::time_t::MAX as u64) as _
 }
 
 impl Condvar {
diff --git a/src/libstd/sys/vxworks/condvar.rs b/src/libstd/sys/vxworks/condvar.rs
index 5a77966d97468..f4e22888f9a91 100644
--- a/src/libstd/sys/vxworks/condvar.rs
+++ b/src/libstd/sys/vxworks/condvar.rs
@@ -13,7 +13,7 @@ const TIMESPEC_MAX: libc::timespec =
     libc::timespec { tv_sec: <libc::time_t>::MAX, tv_nsec: 1_000_000_000 - 1 };
 
 fn saturating_cast_to_time_t(value: u64) -> libc::time_t {
-    if value > <libc::time_t>::MAX as u64 { <libc::time_t>::MAX } else { value as libc::time_t }
+    crate::cmp::min(value, libc::time_t::MAX as u64) as _
 }
 
 impl Condvar {