mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Fix excessive_precision false positive
This commit is contained in:
parent
63ceabf0cf
commit
8a77a25b8a
@ -136,10 +136,10 @@ fn max_digits(fty: FloatTy) -> u32 {
|
|||||||
|
|
||||||
/// Counts the digits excluding leading zeros
|
/// Counts the digits excluding leading zeros
|
||||||
fn count_digits(s: &str) -> usize {
|
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()
|
s.chars()
|
||||||
.filter(|c| *c != '-' || *c != '.')
|
.filter(|c| *c != '-' && *c != '.')
|
||||||
.take_while(|c| *c != 'e' || *c != 'E')
|
.take_while(|c| *c != 'e' && *c != 'E')
|
||||||
.fold(0, |count, c| {
|
.fold(0, |count, c| {
|
||||||
// leading zeros
|
// leading zeros
|
||||||
if c == '0' && count == 0 {
|
if c == '0' && count == 0 {
|
||||||
|
@ -67,4 +67,7 @@ fn main() {
|
|||||||
|
|
||||||
// Inferred type
|
// Inferred type
|
||||||
let good_inferred: f32 = 1f32 * 1_000_000_000.;
|
let good_inferred: f32 = 1f32 * 1_000_000_000.;
|
||||||
|
|
||||||
|
// issue #2840
|
||||||
|
let num = 0.000_000_000_01e-10f64;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user