Skip to content

Commit 6dc066f

Browse files
committed
Includes TODO comment for hypot lint
1 parent db7bc6b commit 6dc066f

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

tests/ui/floating_point_hypot.fixed

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-rustfix
2-
#![warn(clippy::suboptimal_flops, clippy::imprecise_flops)]
2+
#![warn(clippy::imprecise_flops)]
33

44
fn main() {
55
let x = 3f32;
@@ -8,6 +8,7 @@ fn main() {
88
let _ = (x + 1f32).hypot(y);
99
let _ = x.hypot(y);
1010
// Cases where the lint shouldn't be applied
11+
// TODO: linting this adds some complexity, but could be done
1112
let _ = x.mul_add(x, y * y).sqrt();
12-
let _ = x.mul_add(4f32, y * y).sqrt();
13+
let _ = (x * 4f32 + y * y).sqrt();
1314
}

tests/ui/floating_point_hypot.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-rustfix
2-
#![warn(clippy::suboptimal_flops, clippy::imprecise_flops)]
2+
#![warn(clippy::imprecise_flops)]
33

44
fn main() {
55
let x = 3f32;
@@ -8,6 +8,7 @@ fn main() {
88
let _ = ((x + 1f32) * (x + 1f32) + y * y).sqrt();
99
let _ = (x.powi(2) + y.powi(2)).sqrt();
1010
// Cases where the lint shouldn't be applied
11+
// TODO: linting this adds some complexity, but could be done
1112
let _ = x.mul_add(x, y * y).sqrt();
1213
let _ = (x * 4f32 + y * y).sqrt();
1314
}

tests/ui/floating_point_hypot.stderr

+1-9
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,5 @@ error: hypotenuse can be computed more accurately
1818
LL | let _ = (x.powi(2) + y.powi(2)).sqrt();
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.hypot(y)`
2020

21-
error: multiply and add expressions can be calculated more efficiently and accurately
22-
--> $DIR/floating_point_hypot.rs:12:13
23-
|
24-
LL | let _ = (x * 4f32 + y * y).sqrt();
25-
| ^^^^^^^^^^^^^^^^^^ help: consider using: `x.mul_add(4f32, y * y)`
26-
|
27-
= note: `-D clippy::suboptimal-flops` implied by `-D warnings`
28-
29-
error: aborting due to 4 previous errors
21+
error: aborting due to 3 previous errors
3022

0 commit comments

Comments
 (0)