mistyped_literal_suffixes: ignore floats without exponent

Previously this lint would only look at the integer part of floating
point literals without an exponent, giving wrong suggestions like:

```
  |
8 |     let _ = 123_32.123;
  |             ^^^^^^^^^^ help: did you mean to write: `123.123_f32`
  |
```

Instead, it now ignores these literals.
Fixes #6129
This commit is contained in:
goth-turtle 2022-04-24 15:06:48 +02:00
parent f290249461
commit b4a50e9ee5
4 changed files with 10 additions and 2 deletions

View File

@ -308,7 +308,7 @@ impl LiteralDigitGrouping {
let (part, mistyped_suffixes, is_float) = if let Some((_, exponent)) = &mut num_lit.exponent {
(exponent, &["32", "64"][..], true)
} else if num_lit.fraction.is_some() {
(&mut num_lit.integer, &["32", "64"][..], true)
return true;
} else {
(&mut num_lit.integer, &["8", "16", "32", "64"][..], false)
};

View File

@ -35,5 +35,9 @@ fn main() {
let ok35 = 0x12345_16;
let fail36 = 0xFFFF_FFFF_FFFF_FFFF_u64; // u64
// issue #6129
let ok37 = 123_32.123;
let ok38 = 124_64.0;
let _ = 1.123_45E1_f32;
}

View File

@ -35,5 +35,9 @@ fn main() {
let ok35 = 0x12345_16;
let fail36 = 0xFFFF_FFFF_FFFF_FFFF_64; // u64
// issue #6129
let ok37 = 123_32.123;
let ok38 = 124_64.0;
let _ = 1.12345E1_32;
}

View File

@ -91,7 +91,7 @@ LL | let fail36 = 0xFFFF_FFFF_FFFF_FFFF_64; // u64
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean to write: `0xFFFF_FFFF_FFFF_FFFF_u64`
error: mistyped literal suffix
--> $DIR/mistyped_literal_suffix.rs:38:13
--> $DIR/mistyped_literal_suffix.rs:42:13
|
LL | let _ = 1.12345E1_32;
| ^^^^^^^^^^^^ help: did you mean to write: `1.123_45E1_f32`