feat(lint): impl lint about use first() instead of get(0)#8882
Merged
bors merged 4 commits intorust-lang:masterfrom May 25, 2022
Merged
feat(lint): impl lint about use first() instead of get(0)#8882bors merged 4 commits intorust-lang:masterfrom
bors merged 4 commits intorust-lang:masterfrom
Conversation
|
r? @llogiq (rust-highfive has picked a reviewer for you, use r? to override) |
llogiq
reviewed
May 24, 2022
Contributor
llogiq
left a comment
There was a problem hiding this comment.
This is already looking quite good. I only have one small suggestion.
| impl<'tcx> LateLintPass<'tcx> for GetFirst { | ||
| fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) { | ||
| if_chain! { | ||
| if let hir::ExprKind::MethodCall(_, expr_args, _) = &expr.kind; |
Contributor
There was a problem hiding this comment.
Using
Suggested change
| if let hir::ExprKind::MethodCall(_, expr_args, _) = &expr.kind; | |
| if let hir::ExprKind::MethodCall(_, [struct_calling_on, method_arg], _) = &expr.kind; |
would make the expr_args.len() == 2 check and the expr_args.get(_) checks obsolete.
Contributor
|
☔ The latest upstream changes (presumably #8880) made this pull request unmergeable. Please resolve the merge conflicts. |
Contributor
Author
|
I rebased to the latest master and committed your suggestion :) |
Contributor
|
Thank you! @bors r+ |
Contributor
|
📌 Commit d0f93c1 has been approved by |
Contributor
Contributor
|
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
This was referenced May 25, 2022
bors
added a commit
that referenced
this pull request
May 2, 2024
Remove `dead_code` paths The following paths are `dead_code` and can be removed: ### `clippy_utils::paths::VEC_RESIZE` * Introduced when `vec_resize_to_zero` lint added in PR #5637 * No longer used after commit 8acc4d2 ### `clippy_utils::paths::SLICE_GET` * Introduced when `get_first` lint added in PR #8882 * No longer used after commit a8d80d5 ### `clippy_utils::paths::STR_BYTES` * Introduced when `bytes_count_to_len` lint added in PR #8711 * No longer used after commit ba6a459 When the lints were moved into the `Methods` lint pass, they switched from using paths to diagnostic items. However, the paths were never removed. This occurred in PR #8957. This relates to issue #5393 changelog: none
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
close #8851
This PR adds new lint about considering replacing .get(0) with .first().
Thank you in advance.
changelog: adds new lint [
get_first] to consider replacing .get(0) with .first()