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

New lint needless_as_bytes #13437

Merged
merged 2 commits into from
Oct 29, 2024
Merged

New lint needless_as_bytes #13437

merged 2 commits into from
Oct 29, 2024

Conversation

samueltardieu
Copy link
Contributor

changelog: [needless_as_bytes]: new lint

Fix #13434

@rustbot
Copy link
Collaborator

rustbot commented Sep 21, 2024

r? @y21

rustbot has assigned @y21.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Sep 21, 2024
Copy link

@LikeLakers2 LikeLakers2 left a comment

Choose a reason for hiding this comment

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

LGTM, at least documentation-wise. Thank you for making the lint I suggested. :)

@bors
Copy link
Contributor

bors commented Sep 22, 2024

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

@GuillaumeGomez GuillaumeGomez added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Sep 22, 2024
@samueltardieu samueltardieu force-pushed the issue-13434 branch 2 times, most recently from bffedc4 to 1867997 Compare September 22, 2024 17:21
Copy link
Member

@GuillaumeGomez GuillaumeGomez left a comment

Choose a reason for hiding this comment

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

Apart from the missing ui test annotations, looks good to me, nice work!

@samueltardieu
Copy link
Contributor Author

I've added the missing test annotations, thanks for the review!

@samueltardieu
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Sep 22, 2024
@GuillaumeGomez
Copy link
Member

Looks all good to me, thanks! Let's just wait someone from the team to approve it too. :)

Copy link
Member

@y21 y21 left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me already, most of the comments I initially had were mentioned by others and are now resolved :)

clippy_lints/src/needless_as_bytes.rs Outdated Show resolved Hide resolved
tests/ui/needless_as_bytes.rs Show resolved Hide resolved
@samueltardieu samueltardieu force-pushed the issue-13434 branch 2 times, most recently from 7da77c0 to d90eefa Compare September 23, 2024 20:48
@samueltardieu samueltardieu requested a review from y21 September 24, 2024 18:20
@samueltardieu
Copy link
Contributor Author

@y21 Do you see something that needs to be changed?

@y21
Copy link
Member

y21 commented Sep 26, 2024

I'll try to take another look later today

Copy link
Member

@y21 y21 left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Copy link

@LikeLakers2 LikeLakers2 left a comment

Choose a reason for hiding this comment

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

Not a team member, but figured I'd do one final approval of my own, to let you know that I don't see anything else I think needs fixing.

@y21
Copy link
Member

y21 commented Sep 26, 2024

FCP1 thread: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/FCP.3A.20needless_as_bytes

Footnotes

  1. final comment period, a process that all new lints need to go through where others can share "last minute" concerns

@y21 y21 added S-final-comment-period Status: final comment period it will be merged unless new objections are raised (~1 week) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Sep 26, 2024
@samueltardieu
Copy link
Contributor Author

@y21 Any news?

@y21
Copy link
Member

y21 commented Oct 12, 2024

Sorry, have not had much time the last few days. There are some comments on the Zulip thread suggesting that this is something that some people do intentionally write to make it clear that it's the byte length (and this argument is also in the linked issue's drawbacks), so I'd want to see a poll on the Zulip for the category. I'll try to do it later today.

I'm personally in favor of this lint being warn-by-default, but we shouldn't have warn-by-default lints that people find hurts readability.

@LikeLakers2
Copy link

LikeLakers2 commented Oct 13, 2024

@y21 I think it's also worth weighing the possibility of people simply not knowing string.len() == string.as_bytes().len(). Though, whether you'd be weighing it for or against warn-by-default, is up to you.

That said, as long as the lint exists in any capacity, I would be happy with the results.

Copy link
Member

@y21 y21 left a comment

Choose a reason for hiding this comment

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

It's been about a week since I've posted the poll on zulip and the majority agrees with the current category (complexity, warn-by-default), so I'd say we're good to go.

Can you update the #[clippy::version] attribute? Also, you'll probably have to rebase and run cargo dev update_lints since this is going to be the 750th lint

/// let len = "some string".len();
/// let b = "some string".is_empty();
/// ```
#[clippy::version = "1.83.0"]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#[clippy::version = "1.83.0"]
#[clippy::version = "1.84.0"]

@samueltardieu
Copy link
Contributor Author

It's been about a week since I've posted the poll on zulip and the majority agrees with the current category (complexity, warn-by-default), so I'd say we're good to go.

Can you update the #[clippy::version] attribute? Also, you'll probably have to rebase and run cargo dev update_lints since this is going to be the 750th lint

Updated

@y21
Copy link
Member

y21 commented Oct 29, 2024

Thanks (also to @GuillaumeGomez and @LikeLakers2 for helping with reviewing)!

@bors r+

@bors
Copy link
Contributor

bors commented Oct 29, 2024

📌 Commit f152bcb has been approved by y21

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Oct 29, 2024

⌛ Testing commit f152bcb with merge 625d391...

@bors
Copy link
Contributor

bors commented Oct 29, 2024

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: y21
Pushing 625d391 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-final-comment-period Status: final comment period it will be merged unless new objections are raised (~1 week)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Complexity lint against some_string.as_bytes().len()
6 participants