This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +6
-12
lines changed Expand file tree Collapse file tree 3 files changed +6
-12
lines changed Original file line number Diff line number Diff line change 11// run-rustfix
2- #![warn(clippy::suboptimal_flops, clippy:: imprecise_flops)]
2+ #![warn(clippy::imprecise_flops)]
33
44fn 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}
Original file line number Diff line number Diff line change 11// run-rustfix
2- #![ warn( clippy:: suboptimal_flops , clippy :: imprecise_flops) ]
2+ #![ warn( clippy:: imprecise_flops) ]
33
44fn 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}
Original file line number Diff line number Diff line change @@ -18,13 +18,5 @@ error: hypotenuse can be computed more accurately
1818LL | 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
You can’t perform that action at this time.
0 commit comments