about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-08-05 08:00:39 +0000
committerbors <bors@rust-lang.org>2019-08-05 08:00:39 +0000
commit20021bb4c798fe081e45aba5f6b32fa05a2423fa (patch)
treef37a1bcf07a7c9a272b528a3002e1d093ffff08b
parent495a571f098b0756122efe0f9eec7a756d487167 (diff)
parenta332febb04b3a05c72530712bba9bb5b0aab75c8 (diff)
downloadrust-20021bb4c798fe081e45aba5f6b32fa05a2423fa.tar.gz
rust-20021bb4c798fe081e45aba5f6b32fa05a2423fa.zip
Auto merge of #4333 - phansch:rustfix_decimal_literal_representation, r=flip1995
Add run-rustfix for decimal_literal_representation lint

changelog: none

cc #3630
-rw-r--r--tests/ui/decimal_literal_representation.fixed25
-rw-r--r--tests/ui/decimal_literal_representation.rs3
-rw-r--r--tests/ui/decimal_literal_representation.stderr10
3 files changed, 33 insertions, 5 deletions
diff --git a/tests/ui/decimal_literal_representation.fixed b/tests/ui/decimal_literal_representation.fixed
new file mode 100644
index 00000000000..95948154004
--- /dev/null
+++ b/tests/ui/decimal_literal_representation.fixed
@@ -0,0 +1,25 @@
+// run-rustfix
+
+#[warn(clippy::decimal_literal_representation)]
+#[allow(unused_variables)]
+#[rustfmt::skip]
+fn main() {
+    let good = (       // Hex:
+        127,           // 0x7F
+        256,           // 0x100
+        511,           // 0x1FF
+        2048,          // 0x800
+        4090,          // 0xFFA
+        16_371,        // 0x3FF3
+        61_683,        // 0xF0F3
+        2_131_750_925, // 0x7F0F_F00D
+    );
+    let bad = (        // Hex:
+        0x8005,        // 0x8005
+        0xFF00,        // 0xFF00
+        0x7F0F_F00F, // 0x7F0F_F00F
+        0x7FFF_FFFF, // 0x7FFF_FFFF
+        #[allow(overflowing_literals)]
+        0xF0F0_F0F0, // 0xF0F0_F0F0
+    );
+}
diff --git a/tests/ui/decimal_literal_representation.rs b/tests/ui/decimal_literal_representation.rs
index d841f16757a..3f73ebc6e51 100644
--- a/tests/ui/decimal_literal_representation.rs
+++ b/tests/ui/decimal_literal_representation.rs
@@ -1,3 +1,5 @@
+// run-rustfix
+
 #[warn(clippy::decimal_literal_representation)]
 #[allow(unused_variables)]
 #[rustfmt::skip]
@@ -17,6 +19,7 @@ fn main() {
         65_280,        // 0xFF00
         2_131_750_927, // 0x7F0F_F00F
         2_147_483_647, // 0x7FFF_FFFF
+        #[allow(overflowing_literals)]
         4_042_322_160, // 0xF0F0_F0F0
     );
 }
diff --git a/tests/ui/decimal_literal_representation.stderr b/tests/ui/decimal_literal_representation.stderr
index 3a535def197..862b193cec2 100644
--- a/tests/ui/decimal_literal_representation.stderr
+++ b/tests/ui/decimal_literal_representation.stderr
@@ -1,5 +1,5 @@
 error: integer literal has a better hexadecimal representation
-  --> $DIR/decimal_literal_representation.rs:16:9
+  --> $DIR/decimal_literal_representation.rs:18:9
    |
 LL |         32_773,        // 0x8005
    |         ^^^^^^ help: consider: `0x8005`
@@ -7,25 +7,25 @@ LL |         32_773,        // 0x8005
    = note: `-D clippy::decimal-literal-representation` implied by `-D warnings`
 
 error: integer literal has a better hexadecimal representation
-  --> $DIR/decimal_literal_representation.rs:17:9
+  --> $DIR/decimal_literal_representation.rs:19:9
    |
 LL |         65_280,        // 0xFF00
    |         ^^^^^^ help: consider: `0xFF00`
 
 error: integer literal has a better hexadecimal representation
-  --> $DIR/decimal_literal_representation.rs:18:9
+  --> $DIR/decimal_literal_representation.rs:20:9
    |
 LL |         2_131_750_927, // 0x7F0F_F00F
    |         ^^^^^^^^^^^^^ help: consider: `0x7F0F_F00F`
 
 error: integer literal has a better hexadecimal representation
-  --> $DIR/decimal_literal_representation.rs:19:9
+  --> $DIR/decimal_literal_representation.rs:21:9
    |
 LL |         2_147_483_647, // 0x7FFF_FFFF
    |         ^^^^^^^^^^^^^ help: consider: `0x7FFF_FFFF`
 
 error: integer literal has a better hexadecimal representation
-  --> $DIR/decimal_literal_representation.rs:20:9
+  --> $DIR/decimal_literal_representation.rs:23:9
    |
 LL |         4_042_322_160, // 0xF0F0_F0F0
    |         ^^^^^^^^^^^^^ help: consider: `0xF0F0_F0F0`