File tree 3 files changed +6
-12
lines changed
3 files changed +6
-12
lines changed Original file line number Diff line number Diff line change 1
1
// run-rustfix
2
- #![warn(clippy::suboptimal_flops, clippy:: imprecise_flops)]
2
+ #![warn(clippy::imprecise_flops)]
3
3
4
4
fn main() {
5
5
let x = 3f32;
@@ -8,6 +8,7 @@ fn main() {
8
8
let _ = (x + 1f32).hypot(y);
9
9
let _ = x.hypot(y);
10
10
// Cases where the lint shouldn't be applied
11
+ // TODO: linting this adds some complexity, but could be done
11
12
let _ = x.mul_add(x, y * y).sqrt();
12
- let _ = x.mul_add( 4f32, y * y).sqrt();
13
+ let _ = (x * 4f32 + y * y).sqrt();
13
14
}
Original file line number Diff line number Diff line change 1
1
// run-rustfix
2
- #![ warn( clippy:: suboptimal_flops , clippy :: imprecise_flops) ]
2
+ #![ warn( clippy:: imprecise_flops) ]
3
3
4
4
fn main ( ) {
5
5
let x = 3f32 ;
@@ -8,6 +8,7 @@ fn main() {
8
8
let _ = ( ( x + 1f32 ) * ( x + 1f32 ) + y * y) . sqrt ( ) ;
9
9
let _ = ( x. powi ( 2 ) + y. powi ( 2 ) ) . sqrt ( ) ;
10
10
// Cases where the lint shouldn't be applied
11
+ // TODO: linting this adds some complexity, but could be done
11
12
let _ = x. mul_add ( x, y * y) . sqrt ( ) ;
12
13
let _ = ( x * 4f32 + y * y) . sqrt ( ) ;
13
14
}
Original file line number Diff line number Diff line change @@ -18,13 +18,5 @@ error: hypotenuse can be computed more accurately
18
18
LL | let _ = (x.powi(2) + y.powi(2)).sqrt();
19
19
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `x.hypot(y)`
20
20
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
30
22
You can’t perform that action at this time.
0 commit comments