-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #5445 - logan-dev-oss:master, r=flip1995
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](#4892 (comment)), 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.
- Loading branch information
Showing
3 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters