Skip to content

Commit 02705d4

Browse files
authored
Merge pull request #3282 from JoshMcguigan/excessive_precision-2840
Fix excessive_precision false positive
2 parents a16edf8 + 8a77a25 commit 02705d4

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

clippy_lints/src/excessive_precision.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ fn max_digits(fty: FloatTy) -> u32 {
136136

137137
/// Counts the digits excluding leading zeros
138138
fn count_digits(s: &str) -> usize {
139-
// Note that s does not contain the f32/64 suffix
139+
// Note that s does not contain the f32/64 suffix, and underscores have been stripped
140140
s.chars()
141-
.filter(|c| *c != '-' || *c != '.')
142-
.take_while(|c| *c != 'e' || *c != 'E')
141+
.filter(|c| *c != '-' && *c != '.')
142+
.take_while(|c| *c != 'e' && *c != 'E')
143143
.fold(0, |count, c| {
144144
// leading zeros
145145
if c == '0' && count == 0 {

tests/ui/excessive_precision.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,7 @@ fn main() {
6767

6868
// Inferred type
6969
let good_inferred: f32 = 1f32 * 1_000_000_000.;
70+
71+
// issue #2840
72+
let num = 0.000_000_000_01e-10f64;
7073
}

0 commit comments

Comments
 (0)