Skip to content

Conversation

koka831
Copy link
Contributor

@koka831 koka831 commented Nov 1, 2022

Addresses #9290

This PR adds new lint manual_is_ascii_check, which detects comparison with ascii ranges using matches! macros.

As I mentioned as following in the Issue;

Yes, that's true. we'll start small and then grow it.
So I'll try to handle matches! macro with single range as suggested above.

However during writing first version, I was thinking that the changes to support alphabetic and digits will be small patch, so I made a single PR in hope review cost can be reduced.

changelog: add new lint [manual_is_ascii_check]

r? @xFrednet

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 1, 2022
@koka831 koka831 force-pushed the feat/manual_is_ascii_check branch from 684f89c to 2ef025b Compare November 1, 2022 16:03
@xFrednet
Copy link
Contributor

xFrednet commented Nov 3, 2022

However during writing first version, I was thinking that the changes to support alphabetic and digits will be small patch, so I made a single PR in hope review cost can be reduced.

That is totally fine, my comment in the issue was more related to cases like:

assert(matches!(c, 'a'..='z') || matches!(c, 'A'..='Z'))

Which would require more effort with probably little benefit. Adding all is_ascii check at once sounds good to me :)

Copy link
Contributor

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

The implementation and created suggestions are really solid. Awesome work! I've left some small comments, but all of them should be simple to fix.

@koka831
Copy link
Contributor Author

koka831 commented Nov 4, 2022

@xFrednet Thank you for review, I learned a lot!
review me again, please:)

@koka831 koka831 requested a review from xFrednet November 4, 2022 08:37
Copy link
Contributor

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

Excellent, this implementation looks really solid to me. The test covers all cases I can think of. Thank you very much!

Before we merge, could you squash the update commits into one? You're welcome to reach out, if you need any help with the squashing.

modify

fix: allow unused in test code

fix: types in doc comment

Update clippy_lints/src/manual_is_ascii_check.rs

Co-authored-by: Fridtjof Stoldt <[email protected]>

Update clippy_lints/src/manual_is_ascii_check.rs

Co-authored-by: Fridtjof Stoldt <[email protected]>

Update clippy_lints/src/manual_is_ascii_check.rs

Co-authored-by: Fridtjof Stoldt <[email protected]>

fix ui test result

fix: unnecessary format!

chore: apply feedbacks

* check msrvs also for const fn
* check applicability manually
* modify documents
@koka831 koka831 force-pushed the feat/manual_is_ascii_check branch from 0b0e0ef to e4540ad Compare November 7, 2022 07:39
@koka831
Copy link
Contributor Author

koka831 commented Nov 8, 2022

squashed, and confirmed it won't change during the commit. https://github.com/rust-lang/rust-clippy/compare/0b0e0ef191994360dc647dd8fa6f3a7967a2621d..e4540ad65fa14ceebd5145ab771fe4918d170bf1

@xFrednet
Copy link
Contributor

xFrednet commented Nov 8, 2022

This version looks good to me, thank you for the update!

@bors r+

@bors
Copy link
Contributor

bors commented Nov 8, 2022

📌 Commit e4540ad has been approved by xFrednet

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Nov 8, 2022

⌛ Testing commit e4540ad with merge 4abe815...

@bors
Copy link
Contributor

bors commented Nov 8, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: xFrednet
Pushing 4abe815 to master...

@bors bors merged commit 4abe815 into rust-lang:master Nov 8, 2022
@koka831 koka831 deleted the feat/manual_is_ascii_check branch November 10, 2022 16:08
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.

4 participants