about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-06-12 12:28:23 +0200
committerGitHub <noreply@github.com>2020-06-12 12:28:23 +0200
commit7c15f30701d636a7699a7ba8e7d683c351a4bb0a (patch)
tree0e461113aec8f6f91b26ba57d99b45d54ae292f1
parente2e2a0fa832679b16df7d6f5d066c745e2687856 (diff)
parentc9bd35cac3bb43dc15d3b8318fa9b6646b1b0aa7 (diff)
downloadrust-7c15f30701d636a7699a7ba8e7d683c351a4bb0a.tar.gz
rust-7c15f30701d636a7699a7ba8e7d683c351a4bb0a.zip
Rollup merge of #72906 - lzutao:migrate-numeric-assoc-consts, r=dtolnay
Migrate to numeric associated consts

The deprecation PR is #72885

cc #68490
cc rust-lang/rfcs#2700
-rw-r--r--clippy_lints/src/consts.rs10
-rw-r--r--clippy_lints/src/enum_clike.rs2
-rw-r--r--clippy_lints/src/types.rs52
-rw-r--r--tests/ui/cast.rs10
-rw-r--r--tests/ui/implicit_saturating_sub.rs14
-rw-r--r--tests/ui/implicit_saturating_sub.stderr14
6 files changed, 51 insertions, 51 deletions
diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs
index 81ddc8c0067..22c5acca064 100644
--- a/clippy_lints/src/consts.rs
+++ b/clippy_lints/src/consts.rs
@@ -254,11 +254,11 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
                     if let ["core", "num", int_impl, "max_value"] = *def_path;
                     then {
                        let value = match int_impl {
-                           "<impl i8>" => i8::max_value() as u128,
-                           "<impl i16>" => i16::max_value() as u128,
-                           "<impl i32>" => i32::max_value() as u128,
-                           "<impl i64>" => i64::max_value() as u128,
-                           "<impl i128>" => i128::max_value() as u128,
+                           "<impl i8>" => i8::MAX as u128,
+                           "<impl i16>" => i16::MAX as u128,
+                           "<impl i32>" => i32::MAX as u128,
+                           "<impl i64>" => i64::MAX as u128,
+                           "<impl i128>" => i128::MAX as u128,
                            _ => return None,
                        };
                        Some(Constant::Int(value))
diff --git a/clippy_lints/src/enum_clike.rs b/clippy_lints/src/enum_clike.rs
index a1fed3fb6e2..12b62f5cf97 100644
--- a/clippy_lints/src/enum_clike.rs
+++ b/clippy_lints/src/enum_clike.rs
@@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
                                     continue;
                                 }
                             },
-                            ty::Uint(UintTy::Usize) if val > u128::from(u32::max_value()) => {},
+                            ty::Uint(UintTy::Usize) if val > u128::from(u32::MAX) => {},
                             _ => continue,
                         }
                         span_lint(
diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs
index 57d5b27df57..d59a2f1bae0 100644
--- a/clippy_lints/src/types.rs
+++ b/clippy_lints/src/types.rs
@@ -1946,18 +1946,18 @@ fn detect_extreme_expr<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_
     let which = match (&ty.kind, cv) {
         (&ty::Bool, Constant::Bool(false)) | (&ty::Uint(_), Constant::Int(0)) => Minimum,
         (&ty::Int(ity), Constant::Int(i))
-            if i == unsext(cx.tcx, i128::min_value() >> (128 - int_bits(cx.tcx, ity)), ity) =>
+            if i == unsext(cx.tcx, i128::MIN >> (128 - int_bits(cx.tcx, ity)), ity) =>
         {
             Minimum
         },
 
         (&ty::Bool, Constant::Bool(true)) => Maximum,
         (&ty::Int(ity), Constant::Int(i))
-            if i == unsext(cx.tcx, i128::max_value() >> (128 - int_bits(cx.tcx, ity)), ity) =>
+            if i == unsext(cx.tcx, i128::MAX >> (128 - int_bits(cx.tcx, ity)), ity) =>
         {
             Maximum
         },
-        (&ty::Uint(uty), Constant::Int(i)) if clip(cx.tcx, u128::max_value(), uty) == i => Maximum,
+        (&ty::Uint(uty), Constant::Int(i)) if clip(cx.tcx, u128::MAX, uty) == i => Maximum,
 
         _ => return None,
     };
@@ -2039,7 +2039,7 @@ impl FullInt {
     fn cmp_s_u(s: i128, u: u128) -> Ordering {
         if s < 0 {
             Ordering::Less
-        } else if u > (i128::max_value() as u128) {
+        } else if u > (i128::MAX as u128) {
             Ordering::Greater
         } else {
             (s as u128).cmp(&u)
@@ -2084,48 +2084,48 @@ fn numeric_cast_precast_bounds<'a>(cx: &LateContext<'_, '_>, expr: &'a Expr<'_>)
         match pre_cast_ty.kind {
             ty::Int(int_ty) => Some(match int_ty {
                 IntTy::I8 => (
-                    FullInt::S(i128::from(i8::min_value())),
-                    FullInt::S(i128::from(i8::max_value())),
+                    FullInt::S(i128::from(i8::MIN)),
+                    FullInt::S(i128::from(i8::MAX)),
                 ),
                 IntTy::I16 => (
-                    FullInt::S(i128::from(i16::min_value())),
-                    FullInt::S(i128::from(i16::max_value())),
+                    FullInt::S(i128::from(i16::MIN)),
+                    FullInt::S(i128::from(i16::MAX)),
                 ),
                 IntTy::I32 => (
-                    FullInt::S(i128::from(i32::min_value())),
-                    FullInt::S(i128::from(i32::max_value())),
+                    FullInt::S(i128::from(i32::MIN)),
+                    FullInt::S(i128::from(i32::MAX)),
                 ),
                 IntTy::I64 => (
-                    FullInt::S(i128::from(i64::min_value())),
-                    FullInt::S(i128::from(i64::max_value())),
+                    FullInt::S(i128::from(i64::MIN)),
+                    FullInt::S(i128::from(i64::MAX)),
                 ),
-                IntTy::I128 => (FullInt::S(i128::min_value()), FullInt::S(i128::max_value())),
+                IntTy::I128 => (FullInt::S(i128::MIN), FullInt::S(i128::MAX)),
                 IntTy::Isize => (
-                    FullInt::S(isize::min_value() as i128),
-                    FullInt::S(isize::max_value() as i128),
+                    FullInt::S(isize::MIN as i128),
+                    FullInt::S(isize::MAX as i128),
                 ),
             }),
             ty::Uint(uint_ty) => Some(match uint_ty {
                 UintTy::U8 => (
-                    FullInt::U(u128::from(u8::min_value())),
-                    FullInt::U(u128::from(u8::max_value())),
+                    FullInt::U(u128::from(u8::MIN)),
+                    FullInt::U(u128::from(u8::MAX)),
                 ),
                 UintTy::U16 => (
-                    FullInt::U(u128::from(u16::min_value())),
-                    FullInt::U(u128::from(u16::max_value())),
+                    FullInt::U(u128::from(u16::MIN)),
+                    FullInt::U(u128::from(u16::MAX)),
                 ),
                 UintTy::U32 => (
-                    FullInt::U(u128::from(u32::min_value())),
-                    FullInt::U(u128::from(u32::max_value())),
+                    FullInt::U(u128::from(u32::MIN)),
+                    FullInt::U(u128::from(u32::MAX)),
                 ),
                 UintTy::U64 => (
-                    FullInt::U(u128::from(u64::min_value())),
-                    FullInt::U(u128::from(u64::max_value())),
+                    FullInt::U(u128::from(u64::MIN)),
+                    FullInt::U(u128::from(u64::MAX)),
                 ),
-                UintTy::U128 => (FullInt::U(u128::min_value()), FullInt::U(u128::max_value())),
+                UintTy::U128 => (FullInt::U(u128::MIN), FullInt::U(u128::MAX)),
                 UintTy::Usize => (
-                    FullInt::U(usize::min_value() as u128),
-                    FullInt::U(usize::max_value() as u128),
+                    FullInt::U(usize::MIN as u128),
+                    FullInt::U(usize::MAX as u128),
                 ),
             }),
             _ => None,
diff --git a/tests/ui/cast.rs b/tests/ui/cast.rs
index 7e0b211d862..8ee0969b0f0 100644
--- a/tests/ui/cast.rs
+++ b/tests/ui/cast.rs
@@ -37,11 +37,11 @@ fn main() {
     1isize as usize;
     -1isize as usize;
     0i8 as u8;
-    i8::max_value() as u8;
-    i16::max_value() as u16;
-    i32::max_value() as u32;
-    i64::max_value() as u64;
-    i128::max_value() as u128;
+    i8::MAX as u8;
+    i16::MAX as u16;
+    i32::MAX as u32;
+    i64::MAX as u64;
+    i128::MAX as u128;
 
     (-1i8).abs() as u8;
     (-1i16).abs() as u16;
diff --git a/tests/ui/implicit_saturating_sub.rs b/tests/ui/implicit_saturating_sub.rs
index 24cb216e79b..2f32a7b1578 100644
--- a/tests/ui/implicit_saturating_sub.rs
+++ b/tests/ui/implicit_saturating_sub.rs
@@ -110,7 +110,7 @@ fn main() {
     }
 
     // Lint
-    if i_8 > i8::min_value() {
+    if i_8 > i8::MIN {
         i_8 -= 1;
     }
 
@@ -120,7 +120,7 @@ fn main() {
     }
 
     // Lint
-    if i_8 != i8::min_value() {
+    if i_8 != i8::MIN {
         i_8 -= 1;
     }
 
@@ -135,7 +135,7 @@ fn main() {
     }
 
     // Lint
-    if i_16 > i16::min_value() {
+    if i_16 > i16::MIN {
         i_16 -= 1;
     }
 
@@ -145,7 +145,7 @@ fn main() {
     }
 
     // Lint
-    if i_16 != i16::min_value() {
+    if i_16 != i16::MIN {
         i_16 -= 1;
     }
 
@@ -160,7 +160,7 @@ fn main() {
     }
 
     // Lint
-    if i_32 > i32::min_value() {
+    if i_32 > i32::MIN {
         i_32 -= 1;
     }
 
@@ -170,7 +170,7 @@ fn main() {
     }
 
     // Lint
-    if i_32 != i32::min_value() {
+    if i_32 != i32::MIN {
         i_32 -= 1;
     }
 
@@ -180,7 +180,7 @@ fn main() {
     let mut i_64: i64 = endi_64 - starti_64;
 
     // Lint
-    if i64::min_value() < i_64 {
+    if i64::MIN < i_64 {
         i_64 -= 1;
     }
 
diff --git a/tests/ui/implicit_saturating_sub.stderr b/tests/ui/implicit_saturating_sub.stderr
index a8ba870b1dd..2eb2023b3b9 100644
--- a/tests/ui/implicit_saturating_sub.stderr
+++ b/tests/ui/implicit_saturating_sub.stderr
@@ -75,7 +75,7 @@ LL | |     }
 error: Implicitly performing saturating subtraction
   --> $DIR/implicit_saturating_sub.rs:113:5
    |
-LL | /     if i_8 > i8::min_value() {
+LL | /     if i_8 > i8::MIN {
 LL | |         i_8 -= 1;
 LL | |     }
    | |_____^ help: try: `i_8 = i_8.saturating_sub(1);`
@@ -91,7 +91,7 @@ LL | |     }
 error: Implicitly performing saturating subtraction
   --> $DIR/implicit_saturating_sub.rs:123:5
    |
-LL | /     if i_8 != i8::min_value() {
+LL | /     if i_8 != i8::MIN {
 LL | |         i_8 -= 1;
 LL | |     }
    | |_____^ help: try: `i_8 = i_8.saturating_sub(1);`
@@ -107,7 +107,7 @@ LL | |     }
 error: Implicitly performing saturating subtraction
   --> $DIR/implicit_saturating_sub.rs:138:5
    |
-LL | /     if i_16 > i16::min_value() {
+LL | /     if i_16 > i16::MIN {
 LL | |         i_16 -= 1;
 LL | |     }
    | |_____^ help: try: `i_16 = i_16.saturating_sub(1);`
@@ -123,7 +123,7 @@ LL | |     }
 error: Implicitly performing saturating subtraction
   --> $DIR/implicit_saturating_sub.rs:148:5
    |
-LL | /     if i_16 != i16::min_value() {
+LL | /     if i_16 != i16::MIN {
 LL | |         i_16 -= 1;
 LL | |     }
    | |_____^ help: try: `i_16 = i_16.saturating_sub(1);`
@@ -139,7 +139,7 @@ LL | |     }
 error: Implicitly performing saturating subtraction
   --> $DIR/implicit_saturating_sub.rs:163:5
    |
-LL | /     if i_32 > i32::min_value() {
+LL | /     if i_32 > i32::MIN {
 LL | |         i_32 -= 1;
 LL | |     }
    | |_____^ help: try: `i_32 = i_32.saturating_sub(1);`
@@ -155,7 +155,7 @@ LL | |     }
 error: Implicitly performing saturating subtraction
   --> $DIR/implicit_saturating_sub.rs:173:5
    |
-LL | /     if i_32 != i32::min_value() {
+LL | /     if i_32 != i32::MIN {
 LL | |         i_32 -= 1;
 LL | |     }
    | |_____^ help: try: `i_32 = i_32.saturating_sub(1);`
@@ -163,7 +163,7 @@ LL | |     }
 error: Implicitly performing saturating subtraction
   --> $DIR/implicit_saturating_sub.rs:183:5
    |
-LL | /     if i64::min_value() < i_64 {
+LL | /     if i64::MIN < i_64 {
 LL | |         i_64 -= 1;
 LL | |     }
    | |_____^ help: try: `i_64 = i_64.saturating_sub(1);`