-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add lint for comparing floats in an array #4343
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
Changes from 1 commit
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]; | ||
|
||
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(); | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
Could you also add a test for the type
[&f32; 1]
?Playground
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.
Thanks for the help.