Fix missing parenthesis in suboptimal floating point help
This commit is contained in:
parent
2f0f4ddcf7
commit
1ed1001440
5 changed files with 22 additions and 19 deletions
|
|
@ -33,6 +33,9 @@ fn main() {
|
|||
|
||||
let _ = a.mul_add(a, b).sqrt();
|
||||
|
||||
let u = 1usize;
|
||||
let _ = b.mul_add(-(u as f64), a);
|
||||
|
||||
// Cases where the lint shouldn't be applied
|
||||
let _ = (a * a + b * b).sqrt();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ fn main() {
|
|||
|
||||
let _ = (a * a + b).sqrt();
|
||||
|
||||
let u = 1usize;
|
||||
let _ = a - (b * u as f64);
|
||||
|
||||
// Cases where the lint shouldn't be applied
|
||||
let _ = (a * a + b * b).sqrt();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,5 +73,11 @@ error: multiply and add expressions can be calculated more efficiently and accur
|
|||
LL | let _ = (a * a + b).sqrt();
|
||||
| ^^^^^^^^^^^ help: consider using: `a.mul_add(a, b)`
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
error: multiply and add expressions can be calculated more efficiently and accurately
|
||||
--> $DIR/floating_point_mul_add.rs:37:13
|
||||
|
|
||||
LL | let _ = a - (b * u as f64);
|
||||
| ^^^^^^^^^^^^^^^^^^ help: consider using: `b.mul_add(-(u as f64), a)`
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue