Skip to content

New lints [manual_is_infinite] and [manual_is_finite]#11049

Merged
bors merged 3 commits into
rust-lang:masterfrom
Centri3:manual_is_infinite
Jul 8, 2023
Merged

New lints [manual_is_infinite] and [manual_is_finite]#11049
bors merged 3 commits into
rust-lang:masterfrom
Centri3:manual_is_infinite

Conversation

@Centri3

@Centri3 Centri3 commented Jun 30, 2023

Copy link
Copy Markdown
Member

Closes #9665

changelog: New lints [manual_is_infinite] and [manual_is_finite]
#11049

@rustbot

rustbot commented Jun 30, 2023

Copy link
Copy Markdown
Collaborator

r? @xFrednet

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 30, 2023
@bors

bors commented Jul 1, 2023

Copy link
Copy Markdown
Contributor

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

@Centri3 Centri3 force-pushed the manual_is_infinite branch from 6bc229b to 1aa3f21 Compare July 1, 2023 17:33
@asquared31415

Copy link
Copy Markdown
Contributor

x != <float>::INFINITY && x != <float>::NEG_INFINITY returns true for NaN where is_finite returns false.

@Centri3

Centri3 commented Jul 1, 2023

Copy link
Copy Markdown
Member Author

Almost nobody would intentionally account for NaN in those cases regardless. Should add a note about || x.is_nan(), though, and change to MaybeIncorrect

@Centri3

Centri3 commented Jul 1, 2023

Copy link
Copy Markdown
Member Author

We could probably suggest either !x.is_infinite() or x.is_finite() in that case, depending on what they wanted (the original code's behavior or the "fixed" version, respectively). Though x.is_infinite() || x.is_nan() may be more readable than !x.is_infinite()

@xFrednet

xFrednet commented Jul 1, 2023

Copy link
Copy Markdown
Contributor

r ? @blyxyas

Would you mind taking over this review :)

@xFrednet

xFrednet commented Jul 1, 2023

Copy link
Copy Markdown
Contributor

BTW, one thing you might also want to check, is if this is in a const block. I would guess that x != <float>::NEG_INFINITY works in const, while still unstable in const :)

@blyxyas

blyxyas commented Jul 1, 2023

Copy link
Copy Markdown
Member

Yeah, I will take over and control this review. Subjugate it

@Centri3

Centri3 commented Jul 2, 2023

Copy link
Copy Markdown
Member Author

BTW, one thing you might also want to check, is if this is in a const block. I would guess that x != <float>::NEG_INFINITY works in const, while still unstable in const :)

Good point, we can probably check that and make sure const_float_classify is not enabled

Comment thread clippy_lints/src/manual_float_methods.rs Outdated
Comment thread tests/ui/manual_float_methods.rs
Comment thread clippy_lints/src/manual_float_methods.rs
Comment thread tests/ui/manual_float_methods.rs
Comment thread clippy_lints/src/manual_float_methods.rs Outdated
Comment thread clippy_lints/src/manual_float_methods.rs Outdated
@Centri3 Centri3 force-pushed the manual_is_infinite branch 2 times, most recently from 49e864f to fa31c15 Compare July 6, 2023 19:24
@Centri3 Centri3 force-pushed the manual_is_infinite branch from fa31c15 to 536b162 Compare July 7, 2023 01:27

@blyxyas blyxyas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks! ❤️
cc @xFrednet

@xFrednet xFrednet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, just two small nits and then it's ready for bors. Thank you for the implementation!

And thank you @blyxyas for the review :D

Comment thread clippy_lints/src/manual_float_methods.rs Outdated
Comment thread tests/ui/manual_float_methods.rs
@xFrednet

xFrednet commented Jul 7, 2023

Copy link
Copy Markdown
Contributor

You can r=blyxyas,xFrednet after the update :)

Lord bors, I hereby allow queen @Centri3 to merge this PR into the master kingdom, in the name of princess @blyxyas and me ^^

@bors

bors commented Jul 7, 2023

Copy link
Copy Markdown
Contributor

✌️ @Centri3, you can now approve this pull request!

If @xFrednet told you to "r=me" after making some further change, please make that change, then do @bors r=@xFrednet

@Centri3 Centri3 force-pushed the manual_is_infinite branch from 536b162 to 41438c2 Compare July 8, 2023 18:17
@Centri3

Centri3 commented Jul 8, 2023

Copy link
Copy Markdown
Member Author

@bors r=blyxyas,xFrednet

@bors

bors commented Jul 8, 2023

Copy link
Copy Markdown
Contributor

📌 Commit 41438c2 has been approved by blyxyas,xFrednet

It is now in the queue for this repository.

@bors

bors commented Jul 8, 2023

Copy link
Copy Markdown
Contributor

⌛ Testing commit 41438c2 with merge 8e261c0...

@bors

bors commented Jul 8, 2023

Copy link
Copy Markdown
Contributor

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: blyxyas,xFrednet
Pushing 8e261c0 to master...

@bors bors merged commit 8e261c0 into rust-lang:master Jul 8, 2023
@Centri3 Centri3 deleted the manual_is_infinite branch July 8, 2023 23:25
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.

Suggest {f32, f64}::is_finite and {f32, f64}::is_infinite

6 participants