52dacbc876
Fixes issue #4892. First contribution here 😊 ! Do not hesitate to correct me. This PR is related to issue #4892 . # Summary ```rust -literal.method_call(args) ``` The main idea is to not trigger `clippy::precedence` when the method call is an odd function. # Example ```rust // should trigger lint let _ = -1.0_f64.abs() //precedence of method call abs() and neg ('-') is ambiguous // should not trigger lint let _ = -1.0_f64.sin() // sin is an odd function => -sin(x) = sin(-x) ``` # Theory Rust allows following literals: - char - string - integers - floats - byte - bool Only integers/floats implements the relevant `std::ops::Neg`. Following odd functions are implemented on i[8-128] and/or f[32-64]: - `asin` - `asinh` - `atan` - `atanh` - `cbrt` - `fract` - `round` - `signum` - `sin` - `sinh` - `tan` - `tanh ` - `to_degrees` - `to_radians` # Implementation As suggested by `flip1995` in [comment](https://github.com/rust-lang/rust-clippy/issues/4892#issuecomment-568249683), this PR add a whitelist of odd functions and compare method call to the the whitelist before triggering lint. changelog: Don't trigger [`clippy::precedence`] on odd functions. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |