-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing
Description
Summary
The lint imprecise_flops
is not raised when a literal is used in combination with powf
(and maybe other functions as well). Discovered in #9201.
Reproducer
I tried this code:
#![warn(clippy::imprecise_flops)]
fn main() {
let _ = 1.5_f64.powf(1.0 / 3.0);
}
I expected to see this happen:
The lint imprecise_flops
is raised on the line with a message such as "cube-root of a number can be computed more accurately".
Instead, this happened:
No lint is raised.
However, it does work as expected with the following code:
#![warn(clippy::imprecise_flops)]
fn main() {
let x = 1.5_f64;
let _ = x.powf(1.0 / 3.0);
}
// λ cargo clippy
// Checking testuff v0.1.0 (/home/np/code/rust/testuff)
// warning: cube-root of a number can be computed more accurately
// --> src/main.rs:5:13
// |
// 5 | let _ = x.powf(1.0 / 3.0);
// | ^^^^^^^^^^^^^^^^^ help: consider using: `x.cbrt()`
// |
// note: the lint level is defined here
// --> src/main.rs:1:9
// |
// 1 | #![warn(clippy::imprecise_flops)]
// | ^^^^^^^^^^^^^^^^^^^^^^^
// = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#imprecise_flops
Version
rustc 1.65.0-nightly (addacb587 2022-08-24)
binary: rustc
commit-hash: addacb5878b9970ebc1665768a05cb601e7aea15
commit-date: 2022-08-24
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thing