Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

excessive_precision formats large negative exponent wrong #7744

Closed
dtolnay opened this issue Oct 1, 2021 · 0 comments · Fixed by #7747
Closed

excessive_precision formats large negative exponent wrong #7744

dtolnay opened this issue Oct 1, 2021 · 0 comments · Fixed by #7747
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@dtolnay
Copy link
Member

dtolnay commented Oct 1, 2021

fn main() {
    let _ = 2.225_073_858_507_201_1e-308_f64;
}
warning: float has excessive precision
 --> src/main.rs:2:13
  |
2 |     let _ = 2.225_073_858_507_201_1e-308_f64;
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `2.225_073_858_507_201e-_308_f64`
  |
  = note: `#[warn(clippy::excessive_precision)]` on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#excessive_precision

Clippy's suggested diff is:

-     let _ = 2.225_073_858_507_201_1e-308_f64;
+     let _ = 2.225_073_858_507_201e-_308_f64;

which has the floating point exponent written as e-_308 rather than the more readable e-308.

I'm guessing something in the underscore insertion is indirectly based on (-308).to_string().len() > 3.

Meta

Rust version (rustc -Vv):

rustc 1.57.0-nightly (aa7aca3b9 2021-09-30)
binary: rustc
commit-hash: aa7aca3b954131720df725e70d12e902eb3be1de
commit-date: 2021-09-30
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0
@dtolnay dtolnay added the C-bug Category: Clippy is not doing the correct thing label Oct 1, 2021
@bors bors closed this as completed in da3b4b4 Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant