-
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
Add lint for comparing floats in an array #4343
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,13 @@ fn main() { | |
|
||
assert_eq!(a, b); // no errors | ||
|
||
let a1: [f32; 1] = [0.0]; | ||
let a2: [f32; 1] = [1.1]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also add a test for the type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the help. |
||
|
||
assert_eq!(a1[0], a2[0]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we want to do it right, this should not trigger the lint, since everything in On a more general note, this enhancement needs more tests like the base case of comparing floats. (Comparing arrays of constant 0.0, constant {NEG_}INFINITY, ...) |
||
|
||
assert_eq!(&a1[0], &a2[0]); | ||
|
||
// no errors - comparing signums is ok | ||
let x32 = 3.21f32; | ||
1.23f32.signum() == x32.signum(); | ||
|
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 think we also have to
walk_ptrs_ty
onarr_ty
, so that Arrays of&float
s also get linted.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.
On it 🏃
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'm having a bit of an issue getting the
walk_ptrs_ty
to work witharr_ty
; I have updated the tests in the meanwhile. You can have a look if I'm going in the right direction so far.