Merged
Conversation
Contributor
|
☔ The latest upstream changes (presumably #5651) made this pull request unmergeable. Please resolve the merge conflicts. |
Member
|
This looks good btw, just needs to be rebased and have a CI run that doesn't fall over. cc @flip1995 |
flip1995
reviewed
May 27, 2020
| if let ExprKind::Lit(Spanned { node: LitKind::Int(0, _), .. }) = args[1].kind; | ||
| if let ExprKind::Lit(Spanned { node: LitKind::Int(..), .. }) = args[2].kind; | ||
| then { | ||
| span_lint(cx, VEC_RESIZE_TO_ZERO, expr.span, "this empties the vector. It could be an argument inversion mistake. If not, call `clear()` instead."); |
Member
There was a problem hiding this comment.
I would suggest to split up the message and suggestion:
Suggested change
| span_lint(cx, VEC_RESIZE_TO_ZERO, expr.span, "this empties the vector. It could be an argument inversion mistake. If not, call `clear()` instead."); | |
| span_lint_and_then( | |
| cx, | |
| VEC_RESIZE_TO_ZERO, | |
| expr.span, | |
| "emptying a vector with `resize`", | |
| |db| { | |
| db.help("the arguments may be inverted..."); | |
| db.span_suggestion( | |
| resize_span, | |
| "...or you can use `clear` to empty the vector", | |
| "clear()", | |
| Applicability::MaybeIncorrect, | |
| ); | |
| }, | |
| ); |
Note, that you also have to get the span of the method call as resize_span for the suggestion to work.
fb6e6db to
5faab87
Compare
Contributor
Author
|
Should this lint move to the |
Member
|
I think having this in its own module is fine. The methods module is more about methods (chaining) in general, while this is more about arguments to a specific method. |
Member
|
@bors r=yaahc,flip1995 |
Contributor
|
📌 Commit 5faab87 has been approved by |
Contributor
bors
added a commit
that referenced
this pull request
May 31, 2020
…ip1995 new lint: vec_resize_to_zero implements #5444 changelog: new lint vec_resize_to_zero
Member
|
@bors retry (yeeting to rollup) |
Contributor
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.
implements #5444
changelog: new lint vec_resize_to_zero