-
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
float_cmp
changes
#11948
base: master
Are you sure you want to change the base?
float_cmp
changes
#11948
Conversation
r? @giraffate (rustbot has picked a reviewer for you, use r? to override) |
☔ The latest upstream changes (presumably #10283) made this pull request unmergeable. Please resolve the merge conflicts. |
147961e
to
e0a1fc6
Compare
r? clippy |
☔ The latest upstream changes (presumably #12306) made this pull request unmergeable. Please resolve the merge conflicts. |
Hey @Jarcho woudl you mind rebasing this PR? Hey @GuillaumeGomez, if you have the time, could you give this PR a review? r? xFrednet |
f768816
to
b6623ac
Compare
☔ The latest upstream changes (presumably #12999) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a good structure as usual! I've reviewed the implementation and left some comments. Mostly optional nits and some questions. I've started on the tests but haven't checked all of them yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current version looks good to me. I want to wait for a response from @blyxyas, but I don't expect there to be a noticeable impact based on your implementation.
Roses == Red |
`float_cmp` changes fixes #2834 fixes #6816 --- changelog: This: * Deprecated `float_cmp_const` in favor of a config option on [`float_cmp`]. [#11948](#11948) * [`float_cmp`]: Don't lint literal and self comparisons. [#11948](#11948) * [`float_cmp`] [#11948](#11948) * Add the [`float-cmp-ignore-named-constants`] configuration to ignore comparisons to named constants. * Add the [`float-cmp-ignore-change-detection`] configuration to ignore const-evaluatabled values. * Add the [`float-cmp-ignore-constant-comparisons`] configuration to ignore comparisons to the modification of an operand (e.g. `x == f(x)`).
💔 Test failed - checks-action_test |
☔ The latest upstream changes (presumably #13088) made this pull request unmergeable. Please resolve the merge conflicts. |
…constants to `float_cmp`
e1550af
to
083300b
Compare
Latest commit changes named constants to be allowed individually rather than as a group. This feature was originally added to allow comparisons to a sentinel value rather than constants in general. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment and then I'd say it's good to go :D
/// x == VALUE | ||
/// } | ||
/// ``` | ||
(float_cmp_allowed_constants: Vec<String> = Vec::new()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest adding "*"
as a magic value that says that all constants are allowed. THis should also be documented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be better done in a more uniform way across all the multi-value configs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While true, I'm not sure how many lints would benefit from an everything "*"
configuration. #12571 comes to mind, where I also suggested this with a Zulip thread.
An alternative to the current configs would be to have a single heuristics config taking a list of names. e.g. float_cmp_heuristics = ["constant_cmp", "change_detection", "signum_cmp", "cmp_zero"] This would make it possible to preemptively disable future heuristics as well as an easier way to disable all of them. |
Having heuristics as strings in a list feels weird to me. They should be boolean flags IMO. That also makes it easier for format error reporting etc |
☔ The latest upstream changes (presumably #13168) made this pull request unmergeable. Please resolve the merge conflicts. |
fixes #2834
fixes #6816
changelog: This:
float_cmp_const
in favor of a config option on [float_cmp
].#11948
float_cmp
] #11948float-cmp-ignore-named-constants
] configuration to ignore comparisons to named constants.float-cmp-ignore-change-detection
] configuration to ignore const-evaluatabled values.float-cmp-ignore-constant-comparisons
] configuration to ignore comparisons to the modification of an operand (e.g.x == f(x)
).