Includes TODO comment for hypot lint
This commit is contained in:
parent
db7bc6b3bd
commit
6dc066fdb9
@ -1,5 +1,5 @@
|
||||
// run-rustfix
|
||||
#![warn(clippy::suboptimal_flops, clippy::imprecise_flops)]
|
||||
#![warn(clippy::imprecise_flops)]
|
||||
|
||||
fn main() {
|
||||
let x = 3f32;
|
||||
@ -8,6 +8,7 @@ fn main() {
|
||||
let _ = (x + 1f32).hypot(y);
|
||||
let _ = x.hypot(y);
|
||||
// Cases where the lint shouldn't be applied
|
||||
// TODO: linting this adds some complexity, but could be done
|
||||
let _ = x.mul_add(x, y * y).sqrt();
|
||||
let _ = x.mul_add(4f32, y * y).sqrt();
|
||||
let _ = (x * 4f32 + y * y).sqrt();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// run-rustfix
|
||||
#![warn(clippy::suboptimal_flops, clippy::imprecise_flops)]
|
||||
#![warn(clippy::imprecise_flops)]
|
||||
|
||||
fn main() {
|
||||
let x = 3f32;
|
||||
@ -8,6 +8,7 @@ fn main() {
|
||||
let _ = ((x + 1f32) * (x + 1f32) + y * y).sqrt();
|
||||
let _ = (x.powi(2) + y.powi(2)).sqrt();
|
||||
// Cases where the lint shouldn't be applied
|
||||
// TODO: linting this adds some complexity, but could be done
|
||||
let _ = x.mul_add(x, y * y).sqrt();
|
||||
let _ = (x * 4f32 + y * y).sqrt();
|
||||
}
|
||||
|
@ -18,13 +18,5 @@ error: hypotenuse can be computed more accurately
|
||||
LL | let _ = (x.powi(2) + y.powi(2)).sqrt();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.hypot(y)`
|
||||
|
||||
error: multiply and add expressions can be calculated more efficiently and accurately
|
||||
--> $DIR/floating_point_hypot.rs:12:13
|
||||
|
|
||||
LL | let _ = (x * 4f32 + y * y).sqrt();
|
||||
| ^^^^^^^^^^^^^^^^^^ help: consider using: `x.mul_add(4f32, y * y)`
|
||||
|
|
||||
= note: `-D clippy::suboptimal-flops` implied by `-D warnings`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user