Skip to content

Commit 20021bb

Browse files
committed
Auto merge of #4333 - phansch:rustfix_decimal_literal_representation, r=flip1995
Add run-rustfix for decimal_literal_representation lint changelog: none cc #3630
2 parents 495a571 + a332feb commit 20021bb

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// run-rustfix
2+
3+
#[warn(clippy::decimal_literal_representation)]
4+
#[allow(unused_variables)]
5+
#[rustfmt::skip]
6+
fn main() {
7+
let good = ( // Hex:
8+
127, // 0x7F
9+
256, // 0x100
10+
511, // 0x1FF
11+
2048, // 0x800
12+
4090, // 0xFFA
13+
16_371, // 0x3FF3
14+
61_683, // 0xF0F3
15+
2_131_750_925, // 0x7F0F_F00D
16+
);
17+
let bad = ( // Hex:
18+
0x8005, // 0x8005
19+
0xFF00, // 0xFF00
20+
0x7F0F_F00F, // 0x7F0F_F00F
21+
0x7FFF_FFFF, // 0x7FFF_FFFF
22+
#[allow(overflowing_literals)]
23+
0xF0F0_F0F0, // 0xF0F0_F0F0
24+
);
25+
}

tests/ui/decimal_literal_representation.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// run-rustfix
2+
13
#[warn(clippy::decimal_literal_representation)]
24
#[allow(unused_variables)]
35
#[rustfmt::skip]
@@ -17,6 +19,7 @@ fn main() {
1719
65_280, // 0xFF00
1820
2_131_750_927, // 0x7F0F_F00F
1921
2_147_483_647, // 0x7FFF_FFFF
22+
#[allow(overflowing_literals)]
2023
4_042_322_160, // 0xF0F0_F0F0
2124
);
2225
}

tests/ui/decimal_literal_representation.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
error: integer literal has a better hexadecimal representation
2-
--> $DIR/decimal_literal_representation.rs:16:9
2+
--> $DIR/decimal_literal_representation.rs:18:9
33
|
44
LL | 32_773, // 0x8005
55
| ^^^^^^ help: consider: `0x8005`
66
|
77
= note: `-D clippy::decimal-literal-representation` implied by `-D warnings`
88

99
error: integer literal has a better hexadecimal representation
10-
--> $DIR/decimal_literal_representation.rs:17:9
10+
--> $DIR/decimal_literal_representation.rs:19:9
1111
|
1212
LL | 65_280, // 0xFF00
1313
| ^^^^^^ help: consider: `0xFF00`
1414

1515
error: integer literal has a better hexadecimal representation
16-
--> $DIR/decimal_literal_representation.rs:18:9
16+
--> $DIR/decimal_literal_representation.rs:20:9
1717
|
1818
LL | 2_131_750_927, // 0x7F0F_F00F
1919
| ^^^^^^^^^^^^^ help: consider: `0x7F0F_F00F`
2020

2121
error: integer literal has a better hexadecimal representation
22-
--> $DIR/decimal_literal_representation.rs:19:9
22+
--> $DIR/decimal_literal_representation.rs:21:9
2323
|
2424
LL | 2_147_483_647, // 0x7FFF_FFFF
2525
| ^^^^^^^^^^^^^ help: consider: `0x7FFF_FFFF`
2626

2727
error: integer literal has a better hexadecimal representation
28-
--> $DIR/decimal_literal_representation.rs:20:9
28+
--> $DIR/decimal_literal_representation.rs:23:9
2929
|
3030
LL | 4_042_322_160, // 0xF0F0_F0F0
3131
| ^^^^^^^^^^^^^ help: consider: `0xF0F0_F0F0`

0 commit comments

Comments
 (0)