Auto merge of #11836 - lukaslueg:issue11831, r=Alexendoo
Don't suggest `a.mul_add(b, c)` if parameters are not float clippy::suboptimal_flops used to not check if the second parameter to f32/f64.mul_add() was float. Since the method is only defined to take `Self` as parameters, the suggestion was wrong. Fixes #11831 changelog: [`suboptimal_float`]: Don't suggest `a.mul_add(b, c)` if parameters are not f32/f64
This commit is contained in:
commit
e6f33905e8
3 changed files with 42 additions and 2 deletions
|
|
@ -39,3 +39,21 @@ fn main() {
|
|||
// Cases where the lint shouldn't be applied
|
||||
let _ = (a * a + b * b).sqrt();
|
||||
}
|
||||
|
||||
fn _issue11831() {
|
||||
struct NotAFloat;
|
||||
|
||||
impl std::ops::Add<f64> for NotAFloat {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, _: f64) -> Self {
|
||||
NotAFloat
|
||||
}
|
||||
}
|
||||
|
||||
let a = NotAFloat;
|
||||
let b = 1.0_f64;
|
||||
let c = 1.0;
|
||||
|
||||
let _ = a + b * c;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,3 +39,21 @@ fn main() {
|
|||
// Cases where the lint shouldn't be applied
|
||||
let _ = (a * a + b * b).sqrt();
|
||||
}
|
||||
|
||||
fn _issue11831() {
|
||||
struct NotAFloat;
|
||||
|
||||
impl std::ops::Add<f64> for NotAFloat {
|
||||
type Output = Self;
|
||||
|
||||
fn add(self, _: f64) -> Self {
|
||||
NotAFloat
|
||||
}
|
||||
}
|
||||
|
||||
let a = NotAFloat;
|
||||
let b = 1.0_f64;
|
||||
let c = 1.0;
|
||||
|
||||
let _ = a + b * c;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue