Merge pull request #2513 from niklasf/increase-unreadable-literal
Increase unreadable_literal digits (fixes #1958)
This commit is contained in:
commit
9683f38560
@ -375,7 +375,7 @@ impl LiteralDigitGrouping {
|
||||
|
||||
if underscore_positions.is_empty() {
|
||||
// Check if literal needs underscores.
|
||||
if digits.len() > 4 {
|
||||
if digits.len() > 5 {
|
||||
Err(WarningType::UnreadableLiteral)
|
||||
} else {
|
||||
Ok(0)
|
||||
|
@ -3,8 +3,8 @@
|
||||
#[warn(unreadable_literal)]
|
||||
#[allow(unused_variables)]
|
||||
fn main() {
|
||||
let good = (0b1011_i64, 0o1_234_u32, 0x1_234_567, 1_2345_6789, 1234_f32, 1_234.12_f32, 1_234.123_f32, 1.123_4_f32);
|
||||
let bad = (0b10110_i64, 0x12345678901_usize, 12345_f32, 1.23456_f32);
|
||||
let good = (0b1011_i64, 0o1_234_u32, 0x1_234_567, 65536, 1_2345_6789, 1234_f32, 1_234.12_f32, 1_234.123_f32, 1.123_4_f32);
|
||||
let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32);
|
||||
let good_sci = 1.1234e1;
|
||||
let bad_sci = 1.12345e1;
|
||||
let bad_sci = 1.123456e1;
|
||||
}
|
||||
|
@ -1,34 +1,34 @@
|
||||
error: long literal lacking separators
|
||||
--> $DIR/unreadable_literal.rs:7:16
|
||||
|
|
||||
7 | let bad = (0b10110_i64, 0x12345678901_usize, 12345_f32, 1.23456_f32);
|
||||
| ^^^^^^^^^^^ help: consider: `0b1_0110_i64`
|
||||
7 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32);
|
||||
| ^^^^^^^^^^^^ help: consider: `0b11_0110_i64`
|
||||
|
|
||||
= note: `-D unreadable-literal` implied by `-D warnings`
|
||||
|
||||
error: long literal lacking separators
|
||||
--> $DIR/unreadable_literal.rs:7:29
|
||||
--> $DIR/unreadable_literal.rs:7:30
|
||||
|
|
||||
7 | let bad = (0b10110_i64, 0x12345678901_usize, 12345_f32, 1.23456_f32);
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: consider: `0x123_4567_8901_usize`
|
||||
7 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32);
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: consider: `0x123_4567_8901_usize`
|
||||
|
||||
error: long literal lacking separators
|
||||
--> $DIR/unreadable_literal.rs:7:50
|
||||
--> $DIR/unreadable_literal.rs:7:51
|
||||
|
|
||||
7 | let bad = (0b10110_i64, 0x12345678901_usize, 12345_f32, 1.23456_f32);
|
||||
| ^^^^^^^^^ help: consider: `12_345_f32`
|
||||
7 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32);
|
||||
| ^^^^^^^^^^ help: consider: `123_456_f32`
|
||||
|
||||
error: long literal lacking separators
|
||||
--> $DIR/unreadable_literal.rs:7:61
|
||||
--> $DIR/unreadable_literal.rs:7:63
|
||||
|
|
||||
7 | let bad = (0b10110_i64, 0x12345678901_usize, 12345_f32, 1.23456_f32);
|
||||
| ^^^^^^^^^^^ help: consider: `1.234_56_f32`
|
||||
7 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32);
|
||||
| ^^^^^^^^^^^^ help: consider: `1.234_567_f32`
|
||||
|
||||
error: long literal lacking separators
|
||||
--> $DIR/unreadable_literal.rs:9:19
|
||||
|
|
||||
9 | let bad_sci = 1.12345e1;
|
||||
| ^^^^^^^^^ help: consider: `1.123_45e1`
|
||||
9 | let bad_sci = 1.123456e1;
|
||||
| ^^^^^^^^^^ help: consider: `1.123_456e1`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user