-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 bytes_count_to_len
#8375
New lint bytes_count_to_len
#8375
Conversation
…s/rust-clippy into new-lint-bytes-count-to-len
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Manishearth (or someone else) soon. Please see the contribution instructions for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start, some suggestions
#[clippy::version = "1.60.0"] | ||
pub BYTES_COUNT_TO_LEN, | ||
complexity, | ||
"Using bytest().count() when len() performs the same functionality" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Using bytest().count() when len() performs the same functionality" | |
"Using bytes().count() when len() performs the same functionality" |
if_chain! { | ||
//check for method call called "count" | ||
if let hir::ExprKind::MethodCall(count_path, count_args, _) = &expr.kind; | ||
if count_path.ident.name == rustc_span::sym::count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use match_def_path
here and below
And we should ensure the type is str
☔ The latest upstream changes (presumably #8411) made this pull request unmergeable. Please resolve the merge conflicts. |
@c-rus ping from triage. Can you have any question to work on this? |
@c-rus ping from triage. According the triage procedure, I'm closing this because 2 weeks have passed with no activity. If you have more time to work on this, feel free to reopen this. |
I'm interested in this PR. |
Yes, thanks! |
I opened a PR that took over. |
Fixes #8083
changelog:
• adds new lint
[`bytes_count_to_len`]
to consider replacing.bytes().count()
with.len()