Auto merge of #4333 - phansch:rustfix_decimal_literal_representation, r=flip1995
Add run-rustfix for decimal_literal_representation lint changelog: none cc #3630
This commit is contained in:
commit
20021bb4c7
25
tests/ui/decimal_literal_representation.fixed
Normal file
25
tests/ui/decimal_literal_representation.fixed
Normal file
@ -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
|
||||
);
|
||||
}
|
@ -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
|
||||
);
|
||||
}
|
||||
|
@ -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`
|
||||
|
Loading…
Reference in New Issue
Block a user