mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
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:
parent
f290249461
commit
b4a50e9ee5
@ -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)
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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`
|
||||
|
Loading…
Reference in New Issue
Block a user