Skip to content
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

Detect comparisons with NAN constants #4910

Merged

Conversation

krishna-veerareddy
Copy link
Contributor

Currently cmp_nan lint doesn't detect comparisons with NaN's if the operands are consts variables so to fix this we evaluate the const variables first before testing for NaN.

changelog: Detect comparisons with NaN constants in cmp_nan lint

Fixes #1205

Currently `cmp_nan` lint doesn't detect comparisons with NaN's
if the operands are consts variables so to fix this we evaluate
the const variables first before testing for NaN.
`std::{f32,f64}::is_nan` isn't a const fn so prevent `cmp_nan`
lint from running within constant comparisons.
@phansch phansch added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 18, 2019
@phansch
Copy link
Member

phansch commented Dec 18, 2019

@bors r+ thanks!

@bors
Copy link
Collaborator

bors commented Dec 18, 2019

📌 Commit 460d5a3 has been approved by phansch

@bors
Copy link
Collaborator

bors commented Dec 18, 2019

⌛ Testing commit 460d5a3 with merge d7c7056...

bors added a commit that referenced this pull request Dec 18, 2019
…onsts, r=phansch

Detect comparisons with NAN constants

Currently `cmp_nan` lint doesn't detect comparisons with NaN's if the operands are consts variables so to fix this we evaluate the const variables first before testing for NaN.

changelog: Detect comparisons with NaN constants in `cmp_nan` lint

Fixes #1205
@bors
Copy link
Collaborator

bors commented Dec 18, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: phansch
Pushing d7c7056 to master...

@bors bors merged commit 460d5a3 into rust-lang:master Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cmp_nan only compares against NaN constant
3 participants