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

Needless exponent in excessive_precision suggestion #7745

Closed
dtolnay opened this issue Oct 1, 2021 · 1 comment · Fixed by #7774
Closed

Needless exponent in excessive_precision suggestion #7745

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

Comments

@dtolnay
Copy link
Member

dtolnay commented Oct 1, 2021

fn main() {
    let _ = 1.000_000_000_000_001e-324_f64;
}
warning: float has excessive precision
 --> src/main.rs:2:13
  |
2 |     let _ = 1.000_000_000_000_001e-324_f64;
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing the type or truncating it to: `0e0_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 suggests 0e0_f64, but this quantity is more conventionally written as 0_f64 or 0.0_f64. I'm guessing clippy is simplistically doing "if there is e in the original, then use e in the suggestion" but this isn't great for the underflow case.

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
@dswij
Copy link
Member

dswij commented Oct 5, 2021

@rustbot claim

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.

2 participants