diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs
index dc14450e8d22d..338134bb73df1 100644
--- a/src/librustc/mir/mod.rs
+++ b/src/librustc/mir/mod.rs
@@ -2624,7 +2624,13 @@ pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const<'_>) -> fmt::Resu
             Bool if bits == 1 => return write!(f, "true"),
             Float(ast::FloatTy::F32) => return write!(f, "{}f32", Single::from_bits(bits)),
             Float(ast::FloatTy::F64) => return write!(f, "{}f64", Double::from_bits(bits)),
-            Uint(ui) => return write!(f, "{:?}{}", bits, ui),
+            Uint(ui) => {
+                return match bits {
+                    // writing 0 as uX::MIN wouldn't clarify
+                    n if n == ui.max_as_u128() => write!(f, "::std::{}::MAX", ui),
+                    _ => write!(f, "{:?}{}", bits, ui)
+                }
+            }
             Int(i) => {
                 let bit_width = ty::tls::with(|tcx| {
                     let ty = tcx.lift_to_global(&ty).unwrap();
@@ -2634,7 +2640,12 @@ pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const<'_>) -> fmt::Resu
                         .bits()
                 });
                 let shift = 128 - bit_width;
-                return write!(f, "{:?}{}", ((bits as i128) << shift) >> shift, i);
+                let n = ((bits as i128) << shift) >> shift;
+                return match n {
+                    m if m == i.min_as_i128() => write!(f, "::std::{}::MIN", i),
+                    m if m == i.max_as_i128() => write!(f, "::std::{}::MAX", i),
+                    _ => write!(f, "{:?}{}", n, i)
+                }
             }
             Char => return write!(f, "{:?}", ::std::char::from_u32(bits as u32).unwrap()),
             _ => {}
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 0792b2dc49c27..6a56522cbfa28 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -1458,6 +1458,29 @@ impl IntTy {
             IntTy::I128 => 128,
         })
     }
+
+    pub fn min_as_i128(&self) -> i128 {
+        match *self {
+            IntTy::Isize => ::std::isize::MIN as i128,
+            IntTy::I8 => ::std::i8::MIN as i128,
+            IntTy::I16 => ::std::i16::MIN as i128,
+            IntTy::I32 => ::std::i32::MIN as i128,
+            IntTy::I64 => ::std::i64::MIN as i128,
+            IntTy::I128 => ::std::i128::MIN,
+        }
+    }
+
+    pub fn max_as_i128(&self) -> i128 {
+        match *self {
+            IntTy::Isize => ::std::isize::MAX as i128,
+            IntTy::I8 => ::std::i8::MAX as i128,
+            IntTy::I16 => ::std::i16::MAX as i128,
+            IntTy::I32 => ::std::i32::MAX as i128,
+            IntTy::I64 => ::std::i64::MAX as i128,
+            IntTy::I128 => ::std::i128::MAX,
+        }
+    }
+
 }
 
 #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Copy)]
@@ -1496,6 +1519,17 @@ impl UintTy {
             UintTy::U128 => 128,
         })
     }
+
+    pub fn max_as_u128(&self) -> u128 {
+        match *self {
+            UintTy::Usize => ::std::usize::MAX as u128,
+            UintTy::U8 => ::std::u8::MAX as u128,
+            UintTy::U16 => ::std::u16::MAX as u128,
+            UintTy::U32 => ::std::u32::MAX as u128,
+            UintTy::U64 => ::std::u64::MAX as u128,
+            UintTy::U128 => ::std::u128::MAX,
+        }
+    }
 }
 
 impl fmt::Debug for UintTy {
diff --git a/src/test/ui/consts/const-match-check.eval1.stderr b/src/test/ui/consts/const-match-check.eval1.stderr
index 703453e6bdd93..eb1b5494c9b31 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: `-2147483648i32..=-1i32` not covered
+error[E0005]: refutable pattern in local binding: `::std::i32::MIN..=-1i32` not covered
   --> $DIR/const-match-check.rs:35:15
    |
 LL |     A = { let 0 = 0; 0 },
-   |               ^ pattern `-2147483648i32..=-1i32` not covered
+   |               ^ pattern `::std::i32::MIN..=-1i32` not covered
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/consts/const-match-check.eval2.stderr b/src/test/ui/consts/const-match-check.eval2.stderr
index 6caff93e64296..863b68fc23703 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: `-2147483648i32..=-1i32` not covered
+error[E0005]: refutable pattern in local binding: `::std::i32::MIN..=-1i32` not covered
   --> $DIR/const-match-check.rs:41:24
    |
 LL |     let x: [i32; { let 0 = 0; 0 }] = [];
-   |                        ^ pattern `-2147483648i32..=-1i32` not covered
+   |                        ^ pattern `::std::i32::MIN..=-1i32` not covered
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/consts/const-match-check.matchck.stderr b/src/test/ui/consts/const-match-check.matchck.stderr
index 9e45045d27e8d..fba13d409631a 100644
--- a/src/test/ui/consts/const-match-check.matchck.stderr
+++ b/src/test/ui/consts/const-match-check.matchck.stderr
@@ -1,26 +1,26 @@
-error[E0005]: refutable pattern in local binding: `-2147483648i32..=-1i32` not covered
+error[E0005]: refutable pattern in local binding: `::std::i32::MIN..=-1i32` not covered
   --> $DIR/const-match-check.rs:14:22
    |
 LL | const X: i32 = { let 0 = 0; 0 };
-   |                      ^ pattern `-2147483648i32..=-1i32` not covered
+   |                      ^ pattern `::std::i32::MIN..=-1i32` not covered
 
-error[E0005]: refutable pattern in local binding: `-2147483648i32..=-1i32` not covered
+error[E0005]: refutable pattern in local binding: `::std::i32::MIN..=-1i32` not covered
   --> $DIR/const-match-check.rs:18:23
    |
 LL | static Y: i32 = { let 0 = 0; 0 };
-   |                       ^ pattern `-2147483648i32..=-1i32` not covered
+   |                       ^ pattern `::std::i32::MIN..=-1i32` not covered
 
-error[E0005]: refutable pattern in local binding: `-2147483648i32..=-1i32` not covered
+error[E0005]: refutable pattern in local binding: `::std::i32::MIN..=-1i32` not covered
   --> $DIR/const-match-check.rs:23:26
    |
 LL |     const X: i32 = { let 0 = 0; 0 };
-   |                          ^ pattern `-2147483648i32..=-1i32` not covered
+   |                          ^ pattern `::std::i32::MIN..=-1i32` not covered
 
-error[E0005]: refutable pattern in local binding: `-2147483648i32..=-1i32` not covered
+error[E0005]: refutable pattern in local binding: `::std::i32::MIN..=-1i32` not covered
   --> $DIR/const-match-check.rs:29:26
    |
 LL |     const X: i32 = { let 0 = 0; 0 };
-   |                          ^ pattern `-2147483648i32..=-1i32` not covered
+   |                          ^ pattern `::std::i32::MIN..=-1i32` not covered
 
 error: aborting due to 4 previous errors
 
diff --git a/src/test/ui/exhaustive_integer_patterns.stderr b/src/test/ui/exhaustive_integer_patterns.stderr
index 011e93683fb6e..4d7b7f6f9e9f1 100644
--- a/src/test/ui/exhaustive_integer_patterns.stderr
+++ b/src/test/ui/exhaustive_integer_patterns.stderr
@@ -10,11 +10,11 @@ note: lint level defined here
 LL | #![deny(unreachable_patterns)]
    |         ^^^^^^^^^^^^^^^^^^^^
 
-error[E0004]: non-exhaustive patterns: `128u8..=255u8` not covered
+error[E0004]: non-exhaustive patterns: `128u8..=::std::u8::MAX` not covered
   --> $DIR/exhaustive_integer_patterns.rs:38:11
    |
 LL |     match x { //~ ERROR non-exhaustive patterns
-   |           ^ pattern `128u8..=255u8` not covered
+   |           ^ pattern `128u8..=::std::u8::MAX` not covered
 
 error[E0004]: non-exhaustive patterns: `11u8..=19u8`, `31u8..=34u8`, `36u8..=69u8` and 1 more not covered
   --> $DIR/exhaustive_integer_patterns.rs:43:11
@@ -28,17 +28,17 @@ error: unreachable pattern
 LL |         -2..=20 => {} //~ ERROR unreachable pattern
    |         ^^^^^^^
 
-error[E0004]: non-exhaustive patterns: `-128i8..=-8i8`, `-6i8`, `121i8..=124i8` and 1 more not covered
+error[E0004]: non-exhaustive patterns: `::std::i8::MIN..=-8i8`, `-6i8`, `121i8..=124i8` and 1 more not covered
   --> $DIR/exhaustive_integer_patterns.rs:51:11
    |
 LL |     match x { //~ ERROR non-exhaustive patterns
-   |           ^ patterns `-128i8..=-8i8`, `-6i8`, `121i8..=124i8` and 1 more not covered
+   |           ^ patterns `::std::i8::MIN..=-8i8`, `-6i8`, `121i8..=124i8` and 1 more not covered
 
-error[E0004]: non-exhaustive patterns: `-128i8` not covered
+error[E0004]: non-exhaustive patterns: `::std::i8::MIN` not covered
   --> $DIR/exhaustive_integer_patterns.rs:92:11
    |
 LL |     match 0i8 { //~ ERROR non-exhaustive patterns
-   |           ^^^ pattern `-128i8` not covered
+   |           ^^^ pattern `::std::i8::MIN` not covered
 
 error[E0004]: non-exhaustive patterns: `0i16` not covered
   --> $DIR/exhaustive_integer_patterns.rs:100:11
@@ -46,17 +46,17 @@ error[E0004]: non-exhaustive patterns: `0i16` not covered
 LL |     match 0i16 { //~ ERROR non-exhaustive patterns
    |           ^^^^ pattern `0i16` not covered
 
-error[E0004]: non-exhaustive patterns: `128u8..=255u8` not covered
+error[E0004]: non-exhaustive patterns: `128u8..=::std::u8::MAX` not covered
   --> $DIR/exhaustive_integer_patterns.rs:118:11
    |
 LL |     match 0u8 { //~ ERROR non-exhaustive patterns
-   |           ^^^ pattern `128u8..=255u8` not covered
+   |           ^^^ pattern `128u8..=::std::u8::MAX` not covered
 
-error[E0004]: non-exhaustive patterns: `(0u8, Some(_))` and `(2u8..=255u8, Some(_))` not covered
+error[E0004]: non-exhaustive patterns: `(0u8, Some(_))` and `(2u8..=::std::u8::MAX, Some(_))` not covered
   --> $DIR/exhaustive_integer_patterns.rs:130:11
    |
 LL |     match (0u8, Some(())) { //~ ERROR non-exhaustive patterns
-   |           ^^^^^^^^^^^^^^^ patterns `(0u8, Some(_))` and `(2u8..=255u8, Some(_))` not covered
+   |           ^^^^^^^^^^^^^^^ patterns `(0u8, Some(_))` and `(2u8..=::std::u8::MAX, Some(_))` not covered
 
 error[E0004]: non-exhaustive patterns: `(126u8..=127u8, false)` not covered
   --> $DIR/exhaustive_integer_patterns.rs:135:11
@@ -64,17 +64,17 @@ error[E0004]: non-exhaustive patterns: `(126u8..=127u8, false)` not covered
 LL |     match (0u8, true) { //~ ERROR non-exhaustive patterns
    |           ^^^^^^^^^^^ pattern `(126u8..=127u8, false)` not covered
 
-error[E0004]: non-exhaustive patterns: `340282366920938463463374607431768211455u128` not covered
+error[E0004]: non-exhaustive patterns: `::std::u128::MAX` not covered
   --> $DIR/exhaustive_integer_patterns.rs:155:11
    |
 LL |     match 0u128 { //~ ERROR non-exhaustive patterns
-   |           ^^^^^ pattern `340282366920938463463374607431768211455u128` not covered
+   |           ^^^^^ pattern `::std::u128::MAX` not covered
 
-error[E0004]: non-exhaustive patterns: `5u128..=340282366920938463463374607431768211455u128` not covered
+error[E0004]: non-exhaustive patterns: `5u128..=::std::u128::MAX` not covered
   --> $DIR/exhaustive_integer_patterns.rs:159:11
    |
 LL |     match 0u128 { //~ ERROR non-exhaustive patterns
-   |           ^^^^^ pattern `5u128..=340282366920938463463374607431768211455u128` not covered
+   |           ^^^^^ pattern `5u128..=::std::u128::MAX` not covered
 
 error[E0004]: non-exhaustive patterns: `0u128..=3u128` not covered
   --> $DIR/exhaustive_integer_patterns.rs:163:11
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 9b19fc80e2bd6..6b7928b0f3bdc 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: `&-2147483648i32..=0i32` not covered
+error[E0005]: refutable pattern in `for` loop binding: `&::std::i32::MIN..=0i32` not covered
   --> $DIR/for-loop-refutable-pattern-error-message.rs:12:9
    |
 LL |     for &1 in [1].iter() {} //~ ERROR refutable pattern in `for` loop binding
-   |         ^^ pattern `&-2147483648i32..=0i32` not covered
+   |         ^^ pattern `&::std::i32::MIN..=0i32` not covered
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/match/match-non-exhaustive.stderr b/src/test/ui/match/match-non-exhaustive.stderr
index ad895b448dd20..d2291dae87ebc 100644
--- a/src/test/ui/match/match-non-exhaustive.stderr
+++ b/src/test/ui/match/match-non-exhaustive.stderr
@@ -1,8 +1,8 @@
-error[E0004]: non-exhaustive patterns: `-2147483648i32..=0i32` and `2i32..=2147483647i32` not covered
+error[E0004]: non-exhaustive patterns: `::std::i32::MIN..=0i32` and `2i32..=::std::i32::MAX` not covered
   --> $DIR/match-non-exhaustive.rs:12:11
    |
 LL |     match 0 { 1 => () } //~ ERROR non-exhaustive patterns
-   |           ^ patterns `-2147483648i32..=0i32` and `2i32..=2147483647i32` not covered
+   |           ^ patterns `::std::i32::MIN..=0i32` and `2i32..=::std::i32::MAX` not covered
 
 error[E0004]: non-exhaustive patterns: `_` not covered
   --> $DIR/match-non-exhaustive.rs:13:11
diff --git a/src/test/ui/non-exhaustive/non-exhaustive-match.rs b/src/test/ui/non-exhaustive/non-exhaustive-match.rs
index 99a0c5d662660..7fcc53fda5ca5 100644
--- a/src/test/ui/non-exhaustive/non-exhaustive-match.rs
+++ b/src/test/ui/non-exhaustive/non-exhaustive-match.rs
@@ -22,8 +22,8 @@ fn main() {
     match Some(10) { //~ ERROR non-exhaustive patterns: `Some(_)` not covered
       None => {}
     }
-    match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, -2147483648i32..=3i32)`
-                      //  and `(_, _, 5i32..=2147483647i32)` not covered
+    match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, ::std::i32::MIN..=3i32)`
+                      //  and `(_, _, 5i32..=::std::i32::MAX)` not covered
       (_, _, 4) => {}
     }
     match (t::a, t::a) { //~ ERROR non-exhaustive patterns: `(a, a)` not covered
diff --git a/src/test/ui/non-exhaustive/non-exhaustive-match.stderr b/src/test/ui/non-exhaustive/non-exhaustive-match.stderr
index d3703a4445499..fac82abb8e6a9 100644
--- a/src/test/ui/non-exhaustive/non-exhaustive-match.stderr
+++ b/src/test/ui/non-exhaustive/non-exhaustive-match.stderr
@@ -16,11 +16,11 @@ error[E0004]: non-exhaustive patterns: `Some(_)` not covered
 LL |     match Some(10) { //~ ERROR non-exhaustive patterns: `Some(_)` not covered
    |           ^^^^^^^^ pattern `Some(_)` not covered
 
-error[E0004]: non-exhaustive patterns: `(_, _, -2147483648i32..=3i32)` and `(_, _, 5i32..=2147483647i32)` not covered
+error[E0004]: non-exhaustive patterns: `(_, _, ::std::i32::MIN..=3i32)` and `(_, _, 5i32..=::std::i32::MAX)` not covered
   --> $DIR/non-exhaustive-match.rs:25:11
    |
-LL |     match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, -2147483648i32..=3i32)`
-   |           ^^^^^^^^^ patterns `(_, _, -2147483648i32..=3i32)` and `(_, _, 5i32..=2147483647i32)` not covered
+LL |     match (2, 3, 4) { //~ ERROR non-exhaustive patterns: `(_, _, ::std::i32::MIN..=3i32)`
+   |           ^^^^^^^^^ patterns `(_, _, ::std::i32::MIN..=3i32)` and `(_, _, 5i32..=::std::i32::MAX)` not covered
 
 error[E0004]: non-exhaustive patterns: `(a, a)` not covered
   --> $DIR/non-exhaustive-match.rs:29:11
diff --git a/src/test/ui/precise_pointer_size_matching.stderr b/src/test/ui/precise_pointer_size_matching.stderr
index 4acbec6c7ff1a..cb3675f73b189 100644
--- a/src/test/ui/precise_pointer_size_matching.stderr
+++ b/src/test/ui/precise_pointer_size_matching.stderr
@@ -1,14 +1,14 @@
-error[E0004]: non-exhaustive patterns: `$ISIZE_MIN..=-6isize` and `21isize..=$ISIZE_MAX` not covered
+error[E0004]: non-exhaustive patterns: `::std::isize::MIN..=-6isize` and `21isize..=::std::isize::MAX` not covered
   --> $DIR/precise_pointer_size_matching.rs:24:11
    |
 LL |     match 0isize { //~ ERROR non-exhaustive patterns
-   |           ^^^^^^ patterns `$ISIZE_MIN..=-6isize` and `21isize..=$ISIZE_MAX` not covered
+   |           ^^^^^^ patterns `::std::isize::MIN..=-6isize` and `21isize..=::std::isize::MAX` not covered
 
-error[E0004]: non-exhaustive patterns: `0usize` and `21usize..=$USIZE_MAX` not covered
+error[E0004]: non-exhaustive patterns: `0usize` and `21usize..=::std::usize::MAX` not covered
   --> $DIR/precise_pointer_size_matching.rs:29:11
    |
 LL |     match 0usize { //~ ERROR non-exhaustive patterns
-   |           ^^^^^^ patterns `0usize` and `21usize..=$USIZE_MAX` not covered
+   |           ^^^^^^ patterns `0usize` and `21usize..=::std::usize::MAX` not covered
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/refutable-pattern-errors.rs b/src/test/ui/refutable-pattern-errors.rs
index a140e421a5706..9b6492c76a1ed 100644
--- a/src/test/ui/refutable-pattern-errors.rs
+++ b/src/test/ui/refutable-pattern-errors.rs
@@ -14,5 +14,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: `(-2147483648i32..=0i32, _)` not covered
+    //~^ ERROR refutable pattern in local binding: `(::std::i32::MIN..=0i32, _)` not covered
 }
diff --git a/src/test/ui/refutable-pattern-errors.stderr b/src/test/ui/refutable-pattern-errors.stderr
index 42aa572789522..aeff335d86e32 100644
--- a/src/test/ui/refutable-pattern-errors.stderr
+++ b/src/test/ui/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: `(-2147483648i32..=0i32, _)` not covered
+error[E0005]: refutable pattern in local binding: `(::std::i32::MIN..=0i32, _)` not covered
   --> $DIR/refutable-pattern-errors.rs:16:9
    |
 LL |     let (1, (Some(1), 2..=3)) = (1, (None, 2));
-   |         ^^^^^^^^^^^^^^^^^^^^^ pattern `(-2147483648i32..=0i32, _)` not covered
+   |         ^^^^^^^^^^^^^^^^^^^^^ pattern `(::std::i32::MIN..=0i32, _)` not covered
 
 error: aborting due to 2 previous errors