-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes issue #4892. #5445
Merged
Merged
Fixes issue #4892. #5445
Conversation
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
ghost
changed the title
[WIP] Fixes issue #4892.
Fixes issue #4892.
Apr 11, 2020
phansch
added
the
S-waiting-on-author
Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
label
Apr 15, 2020
I integrated recommended changes and rebase upstream/master. |
@bors r+ Thanks! |
📌 Commit 66b855c has been approved by |
bors
added a commit
that referenced
this pull request
Apr 17, 2020
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.
💔 Test failed - checks-action_test |
@bors retry |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-author
Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First contribution here 😊 ! Do not hesitate to correct me.
This PR is related to issue #4892 .
Summary
The main idea is to not trigger
clippy::precedence
when the method call is an odd function.Example
Theory
Rust allows following literals:
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, 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.