7

Uplift `clippy::cmp_nan` lint by Urgau · Pull Request #111818 · rust-lang/rust ·...

 1 year ago
source link: https://github.com/rust-lang/rust/pull/111818
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Uplift clippy::cmp_nan lint #111818

Conversation

Contributor

@Urgau Urgau

commented

May 21, 2023

edited

This PR aims at uplifting the clippy::cmp_nan lint into rustc.

invalid_nan_comparisons

(deny-by-default) (warn-by-default)

The invalid_nan_comparisons lint checks comparison with f32::NAN or f64::NAN as one of the operand.

Example

let a = 2.3f32;
if a == f32::NAN {}

Explanation

NaN does not compare meaningfully to anything – not even itself – so those comparisons are always false.


Mostly followed the instructions for uplifting a clippy lint described here: #99696 (review)

@rustbot label: +I-lang-nominated
r? compiler

rustbot

added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

labels

May 21, 2023

Collaborator

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

rustbot

added the I-lang-nominated Indicates that an issue has been nominated for discussion during a lang team meeting. label

May 21, 2023

This comment has been minimized.

Contributor

Is there some idea why some correctness lints uplifted and others no? I'm expecting that uplifted lints should hit some code often (to be inside rustc), but thinking that anyone playing with NaN's quite rare (looking at github search).

Contributor

Author

Urgau

commented

May 21, 2023

edited

Is there some idea why some correctness lints uplifted and others no? I'm expecting that uplifted lints should hit some code often (to be inside rustc), but thinking that anyone playing with NaN's quite rare (looking at github search).

Doing a simple search in github reveals quite a few instances of people doing direct comparisons against f[32,64}::NAN; it's not huge, but it's not zero either, and I think a lot of that is down to the lint, which is what motivated me to uplift that lint.

Concerning why some lints are being uplifted and not others, I believe this is simply due to two things, man power (it takes quite a few hours, in particular for lints that don't have good diagnostics) and whenever they detect actual bugs with zero false-positive.

Contributor

Using clippy is user's desire, and don't affect anyone except him; but uplifting lints means that now all users will pay that (almost zero, i assume in current case; there was perf run with disabled lints somewhere) price.

Contributor

Author

Urgau

commented

May 21, 2023

edited

Using clippy is user's desire, and don't affect anyone except him; but uplifting lints means that now all users will pay that (almost zero, i assume in current case; there was perf run with disabled lints somewhere) price.

You're right there is a cost (I expect this lint to have near zero impact), which is why I only try to uplift meaningful (UB/near UB/"obviously not what was intended and is wrong") clippy lints.

Contributor

r? compiler

Contributor

umbrella The latest upstream changes (presumably #111848) made this pull request unmergeable. Please resolve the merge conflicts.

This comment was marked as outdated.

This comment was marked as outdated.

rfcbot

added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it.

labels

May 23, 2023

This comment was marked as outdated.

This comment was marked as outdated.

rfcbot

removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it.

labels

May 23, 2023

nikomatsakis

removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

labels

May 23, 2023

Contributor

@rustbot labels +T-lang

rustbot

added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label

May 23, 2023

Contributor

@rfcbot merge

@rfcbot concern warn-by-default

In the lang team meeting we agreed we want this lint, but that we should make it warn-by-default to keep it consistent with other lints (and reserve deny-by-default for things like insta-UB).

dtolnay reacted with thumbs up emojiasquared31415 reacted with confused emoji

Team member @tmandry has proposed to merge this. The next step is review by the rest of the tagged team members:

Concerns:

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns.
See this document for info about what commands tagged team members can give me.

rustbot

removed T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. A-testsuite Area: The testsuite used to check the correctness of rustc

labels

Jun 9, 2023

This comment has been minimized.

rustbot

added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label

Jun 9, 2023

Contributor

hourglass Trying commit 88ed4ce with merge b663820...

Contributor

sunny Try build successful - checks-actions
Build commit: b663820 (b663820c694a10662705f377280fd6f68105f4c7)

This comment has been minimized.

Collaborator

Finished benchmarking commit (b663820): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

Cycles

Results

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 649.669s -> 649.783s (0.02%)

rustbot

removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label

Jun 9, 2023

Contributor

Author

@cjgillot perf is clean and the failing test doesn't fail anymore (see comment)

Could you take a quick look and re-approve the PR.

Contributor

Thanks!
@bors r+

Contributor

pushpin Commit a814537 has been approved by cjgillot

It is now in the queue for this repository.

bors

added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

labels

Jun 10, 2023

Contributor

hourglass Testing commit a814537 with merge 788c98d...

Contributor

sunny Test successful - checks-actions
Approved by: cjgillot
Pushing 788c98d to master...

bors

added the merged-by-bors This PR was explicitly merged by bors label

Jun 10, 2023

bors

merged commit 788c98d into

rust-lang:master

Jun 10, 2023

12 checks passed

Collaborator

Finished benchmarking commit (788c98d): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 648.462s -> 649.15s (0.11%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

cjgillot

cjgillot left review comments
Assignees

cjgillot

Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. merged-by-bors This PR was explicitly merged by bors S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects

None yet

Milestone

1.72.0

Development

Successfully merging this pull request may close these issues.

None yet

15 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK