Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add run-rustfix for decimal_literal_representation lint #4333

Merged
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -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,31 +1,31 @@
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`
|
= 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`
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.