Merge pull request #3282 from JoshMcguigan/excessive_precision-2840

Fix excessive_precision false positive
This commit is contained in:
Oliver S̶c̶h̶n̶e̶i̶d̶e̶r Scherer 2018-10-08 08:24:13 +02:00 committed by GitHub
commit 02705d4cf5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -136,10 +136,10 @@ fn max_digits(fty: FloatTy) -> u32 {
/// Counts the digits excluding leading zeros
fn count_digits(s: &str) -> usize {
// Note that s does not contain the f32/64 suffix
// Note that s does not contain the f32/64 suffix, and underscores have been stripped
s.chars()
.filter(|c| *c != '-' || *c != '.')
.take_while(|c| *c != 'e' || *c != 'E')
.filter(|c| *c != '-' && *c != '.')
.take_while(|c| *c != 'e' && *c != 'E')
.fold(0, |count, c| {
// leading zeros
if c == '0' && count == 0 {

View file

@ -67,4 +67,7 @@ fn main() {
// Inferred type
let good_inferred: f32 = 1f32 * 1_000_000_000.;
// issue #2840
let num = 0.000_000_000_01e-10f64;
}