Merge pull request #2513 from niklasf/increase-unreadable-literal

Increase unreadable_literal digits (fixes #1958)
This commit is contained in:
Oliver Schneider 2018-03-06 14:35:18 +01:00 committed by GitHub
commit 9683f38560
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 17 deletions

View file

@ -375,7 +375,7 @@ impl LiteralDigitGrouping {
if underscore_positions.is_empty() { if underscore_positions.is_empty() {
// Check if literal needs underscores. // Check if literal needs underscores.
if digits.len() > 4 { if digits.len() > 5 {
Err(WarningType::UnreadableLiteral) Err(WarningType::UnreadableLiteral)
} else { } else {
Ok(0) Ok(0)

View file

@ -3,8 +3,8 @@
#[warn(unreadable_literal)] #[warn(unreadable_literal)]
#[allow(unused_variables)] #[allow(unused_variables)]
fn main() { 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 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 = (0b10110_i64, 0x12345678901_usize, 12345_f32, 1.23456_f32); let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32);
let good_sci = 1.1234e1; let good_sci = 1.1234e1;
let bad_sci = 1.12345e1; let bad_sci = 1.123456e1;
} }

View file

@ -1,34 +1,34 @@
error: long literal lacking separators error: long literal lacking separators
--> $DIR/unreadable_literal.rs:7:16 --> $DIR/unreadable_literal.rs:7:16
| |
7 | let bad = (0b10110_i64, 0x12345678901_usize, 12345_f32, 1.23456_f32); 7 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32);
| ^^^^^^^^^^^ help: consider: `0b1_0110_i64` | ^^^^^^^^^^^^ help: consider: `0b11_0110_i64`
| |
= note: `-D unreadable-literal` implied by `-D warnings` = note: `-D unreadable-literal` implied by `-D warnings`
error: long literal lacking separators 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); 7 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32);
| ^^^^^^^^^^^^^^^^^^^ help: consider: `0x123_4567_8901_usize` | ^^^^^^^^^^^^^^^^^^^ help: consider: `0x123_4567_8901_usize`
error: long literal lacking separators 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); 7 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32);
| ^^^^^^^^^ help: consider: `12_345_f32` | ^^^^^^^^^^ help: consider: `123_456_f32`
error: long literal lacking separators 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); 7 | let bad = (0b110110_i64, 0x12345678901_usize, 123456_f32, 1.234567_f32);
| ^^^^^^^^^^^ help: consider: `1.234_56_f32` | ^^^^^^^^^^^^ help: consider: `1.234_567_f32`
error: long literal lacking separators error: long literal lacking separators
--> $DIR/unreadable_literal.rs:9:19 --> $DIR/unreadable_literal.rs:9:19
| |
9 | let bad_sci = 1.12345e1; 9 | let bad_sci = 1.123456e1;
| ^^^^^^^^^ help: consider: `1.123_45e1` | ^^^^^^^^^^ help: consider: `1.123_456e1`
error: aborting due to 5 previous errors error: aborting due to 5 previous errors